From: "Dmitry V. Levin" <ldv@altlinux.org>
To: ALT Devel discussion list <devel@altlinux.ru>
Subject: Re: [devel] Re: Restricted shell for cvs over ssh
Date: Tue, 29 Oct 2002 17:50:12 +0300
Message-ID: <20021029145012.GA10143@basalt.office.altlinux.ru> (raw)
In-Reply-To: <20021029173236.68a37c1c.vyt@vzljot.ru>
[-- Attachment #1.1: Type: text/plain, Size: 736 bytes --]
On Tue, Oct 29, 2002 at 05:32:36PM +0300, Vitaly Ostanin wrote:
> > > Если не секрет, что такое хитрое запущено на хосте devel, что
> > > не даёт нормального shell'а, но даёт возможность использовать
> > > cvs over ssh ?
> >
> > Специальный wrapper:
> > $ wc master/alt_sh.c
> > 101 288 2112 master/alt_sh.c
>
> А он как бы... ну... попробовать дают? :))
>
> > > Собрался cvs у себя завести, хочется по уму :)
> >
> > Только для cvs?
> > На devel.altlinux.ru есть ещё и rsync.
>
> Да, это мне только для cvs.
Вот пример такого shell'а.
Естественно, что приведённый в нем путь к chroot'у надо заменить на
реальный.
Помещают такие программы обычно в /usr/local/sbin/,
с правами %attr(4710,root,группа_доступа).
--
ldv
[-- Attachment #1.2: cvs_sh.c --]
[-- Type: text/plain, Size: 1491 bytes --]
#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <error.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/types.h>
#include <pwd.h>
int
main (int ac, char *av[])
{
const char *dir = "/path/to/chroot";
const char *file = 0;
struct passwd *pw;
uid_t uid = getuid ();
if (!uid)
error (EXIT_FAILURE, 0, "must be non-root");
if (chdir (dir) < 0)
error (EXIT_FAILURE, errno, "chdir");
if (chroot (".") < 0)
error (EXIT_FAILURE, errno, "chroot");
if (setuid (uid) < 0)
error (EXIT_FAILURE, errno, "setuid");
pw = getpwuid (uid);
if (!pw)
error (EXIT_FAILURE, errno, "getpwuid");
if (!pw->pw_dir)
error (EXIT_FAILURE, 0, "invalid home directory");
if (chdir (pw->pw_dir) < 0)
error (EXIT_FAILURE, errno, "chdir");
if (setenv ("HOME", pw->pw_dir, 1) < 0)
error (EXIT_FAILURE, errno, "setenv: HOME");
if (setenv ("USER", pw->pw_name, 1) < 0)
error (EXIT_FAILURE, errno, "setenv: USER");
if (setenv ("PATH", "/bin", 1) < 0)
error (EXIT_FAILURE, errno, "setenv: PATH");
if (3 == ac)
{
if (strcmp ("-c", av[1]))
error (EXIT_FAILURE, EINVAL, "%s", av[1]);
if (!strcmp ("cvs server", av[2]))
{
const char *args[] = { "cvs", "server", 0 };
file = "/bin/cvs";
execv (file, (char *const *) args);
error (EXIT_FAILURE, errno, "execv: %s", file);
}
error (EXIT_FAILURE, EINVAL, "%s", av[2]);
}
error (EXIT_FAILURE, 0, "invalid arguments");
return EXIT_FAILURE;
}
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2002-10-29 14:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-29 13:16 [devel] " Vitaly Ostanin
2002-10-29 13:27 ` Nazar Yurpeak
2002-10-29 13:57 ` [devel] " Vitaly Ostanin
2002-10-29 14:03 ` [devel] " Dmitry V. Levin
2002-10-29 14:32 ` [devel] " Vitaly Ostanin
2002-10-29 14:50 ` Dmitry V. Levin [this message]
2002-10-29 15:07 ` Vitaly Ostanin
2002-10-29 15:00 ` Sergey Bolshakov
2002-11-01 10:31 ` Vitaly Ostanin
2002-11-01 10:44 ` Sergey Bolshakov
2002-11-01 12:49 ` Vitaly Ostanin
2002-11-01 10:45 ` Alexander Bokovoy
2002-11-02 10:27 ` Alexey Morozov
2002-11-02 19:18 ` Dmitry V. Levin
2002-11-03 13:11 ` Alexey Morozov
2002-11-03 11:42 ` Dmitry V. Levin
2002-11-03 15:08 ` Alexey Morozov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021029145012.GA10143@basalt.office.altlinux.ru \
--to=ldv@altlinux.org \
--cc=devel@altlinux.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
ALT Linux Team development discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
public-inbox-index devel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git