barrett@Daisy.EE.UND.AC.ZA (Alan P. Barrett) (03/26/91)
[This is a followup to an article in comp.lang.perl. comp.mail.misc is probably not the right place for it, either, but it doesn't seem too unreasonable.] In article <126122@uunet.UU.NET>, rbj@uunet.UU.NET (Root Boy Jim) writes: > Distribution: usa Hmm. Some of us outside the USA arrange to get these articles anyway. > That number is for UUCP only, not kermit. We do plan on making > anonymous kermit available sometime in the future. Then you might be interested in my anonymous kermit setup. It is not very well tested, and I cannot guarantee that there are no security holes. Extracts from /etc/passwd: ftp:*:25:100:,anonymous ftp:/usr/ftp/anon:/bin/false kermit::27:100:,anonymous kermit:/usr/ftp/anon:/usr/local/bin/anon-kermit I am appending a shar of the anon-kermit program itself, and the kermit.rc file that I install in the etc directory below the anonymous-ftp chroot directory. I wanted to write this in perl, but get a compliant about "you haven't disabled suid scripts in your kernel" or something like that. How can I disable suid scripts? (HP-UX 7.0 on an hp9000 series 300) --apb Alan Barrett, Dept. of Electronic Eng., Univ. of Natal, Durban, South Africa Internet: barrett@ee.und.ac.za UUCP: m2xenix!quagga!undeed!barrett # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by Alan P Barrett <barrett@undeed> on Tue Mar 26 12:55:19 1991 # # This archive contains: # anon-kermit.c kermit.rc # LANG=""; export LANG PATH=/bin:/usr/bin:$PATH; export PATH echo x - anon-kermit.c cat >anon-kermit.c <<'@EOF' /* @(#)anon-kermit.c 1.1 91/03/26 */ /* anon-kermit.c * A P Barrett, Feb 1991 * * Intended as the login shell for an anonymous-kermit account, * which will have access to the anonymous-ftp directory. * * What this program does: * 1. chdir() and chroot() to the anonymous ftp directory. * 2. setgid() and setuid() to the anonymous ftp user id. * 3. exec kermit, with options that tell it to read the startup * file in /etc/kermit.rc. * * Other requirements: * 1. /etc/passwd must contain a dummy entry for a user named 'ftp'. * The uid and gid fields must be something harmless. The home * directory must be the root of the anonymous ftp area. (The * ftp server probbaly requires exactly the same thing in the * /etc/passwd file). * 2. The chroot()ed filesystem used by anonymous ftp must contain * the following files: * a. /bin/kermit (the kermit program) * b. /etc/kermit.rc (startup file for kermit) * c. /dev/tty (must have same major and minor numbers as the * real /dev/tty in the root filesystem) * d. /bin/sh (for kermit to execute various commands) * e. /bin/ls (for directory listings) * f. /bin/rm (for deleting files through kermit) (optional) * 3. This program must be suid-root * */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <pwd.h> int main (argc, argv) int argc; char **argv; { struct passwd *ftp_pw; /* get info from dummy 'ftp' entry in passwd file. * we are interested in uid, gid and home directory */ if ((ftp_pw = getpwnam ("ftp")) == NULL) { (void) fprintf (stderr, "%s: cannot get user information\n", argv[0]); exit (1); } /* tidy environment */ if (putenv ("PATH=/bin") != 0 || putenv ("SHELL=/bin/sh") != 0 || putenv ("IFS= \t\f") != 0 || putenv ("HOME=/") != 0) { (void) fprintf (stderr, "%s: cannot set environment\n", argv[0]); exit (1); } /* chroot to the correct directory */ if (chdir (ftp_pw->pw_dir) != 0 || chroot (".") != 0) { (void) fprintf (stderr, "%s: cannot chdir or chroot\n", argv[0]); exit (1); } /* set uid/gid to the anon ftp user */ if (setgid (ftp_pw->pw_gid) != 0 || setuid (ftp_pw->pw_uid) != 0) { (void) fprintf (stderr, "%s: cannot setgid or setuid\n", argv[0]); exit (1); } (void) execl ("/bin/kermit", "anon-kermit", "-y", "/etc/kermit.rc", "-x", (char *) 0); /* if we get here */ { (void) fprintf (stderr, "%s: cannot run kermit\n", argv[0]); exit (1); } } @EOF chmod 444 anon-kermit.c echo x - kermit.rc cat >kermit.rc <<'@EOF' disable host disable who # disable delete # why bother? ftp allows delete @EOF chmod 444 kermit.rc exit 0