1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-13 10:02:38 +00:00

Various updates to the anonymous ftp support:

- Allow the upload directory to be optional.  If the upload directory
  field is cleared to the empty string then no directory will be created.
- Don't create a bin/ subdirectory in ftp's home dir containing ls(1) and
  date(1) as ftpd(8) no longer requires it.
- Create a pwd.db file in etc/ instead of a passwd file.
- Ignore NIS compat entries in /etc/group and /etc/master.passwd when
  building the anonymous files.

PR:		bin/60662
Submitted by:	Olafur Osvaldsson oli at isnic dot is
This commit is contained in:
John Baldwin 2004-11-16 19:06:42 +00:00
parent ae56b59f8b
commit 60ede768f7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=137781

View File

@ -105,7 +105,7 @@ static Layout layout[] = {
tconf.homedir, STRINGOBJ, NULL },
#define LAYOUT_UPLOAD 4
{ 14, 20, 22, ANONFTP_UPLOAD_LEN - 1,
"Upload Subdirectory:", "Designated sub-directory that holds uploads",
"Upload Subdirectory:", "Designated sub-directory that holds uploads (leave empty for none)",
tconf.upload, STRINGOBJ, NULL },
#define LAYOUT_OKBUTTON 5
{ 19, 15, 0, 0,
@ -248,6 +248,9 @@ configAnonFTP(dialogMenuItem *self __unused)
"ftpd(8) in inetd.conf(5) for FTP services to be available. If you\n"
"did not do so earlier, you will have the opportunity to enable inetd(8)\n"
"again later.\n\n"
"If you want the server to be read-only you should leave the upload\n"
"directory option empty and add the -r command-line option to ftpd(8)\n"
"in inetd.conf(5)\n\n"
"Do you wish to continue configuring anonymous FTP?")) {
return DITEM_FAILURE;
}
@ -268,9 +271,6 @@ configAnonFTP(dialogMenuItem *self __unused)
if (!tconf.group[0])
SAFE_STRCPY(tconf.group, FTP_GROUP);
if (!tconf.upload[0])
SAFE_STRCPY(tconf.upload, FTP_UPLOAD);
/*** If the user did not specify a directory, use default ***/
if (tconf.homedir[strlen(tconf.homedir) - 1] == '/')
@ -287,18 +287,19 @@ configAnonFTP(dialogMenuItem *self __unused)
if (directory_exists(tconf.homedir)) {
msgNotify("Configuring %s for use by anon FTP.", tconf.homedir);
vsystem("chmod 555 %s && chown root.%s %s", tconf.homedir, tconf.group, tconf.homedir);
vsystem("mkdir %s/bin && chmod 555 %s/bin", tconf.homedir, tconf.homedir);
vsystem("cp /bin/ls %s/bin && chmod 111 %s/bin/ls", tconf.homedir, tconf.homedir);
vsystem("cp /bin/date %s/bin && chmod 111 %s/bin/date", tconf.homedir, tconf.homedir);
vsystem("mkdir %s/etc && chmod 555 %s/etc", tconf.homedir, tconf.homedir);
vsystem("mkdir -p %s/pub", tconf.homedir);
vsystem("mkdir -p %s/%s", tconf.homedir, tconf.upload);
vsystem("chmod 1777 %s/%s", tconf.homedir, tconf.upload);
if (tconf.upload[0]) {
vsystem("mkdir -p %s/%s", tconf.homedir, tconf.upload);
vsystem("chmod 1777 %s/%s", tconf.homedir, tconf.upload);
}
if (DITEM_STATUS(createFtpUser()) == DITEM_SUCCESS) {
msgNotify("Copying password information for anon FTP.");
vsystem("awk -F: '{if ($3 < 10 || $1 == \"ftp\") print $0}' /etc/passwd > %s/etc/passwd && chmod 444 %s/etc/passwd", tconf.homedir, tconf.homedir);
vsystem("awk -F: '{if ($3 < 100) print $0}' /etc/group > %s/etc/group && chmod 444 %s/etc/group", tconf.homedir, tconf.homedir);
vsystem("awk -F: '{if ((substr($1, 1, 1) != \"+\") && (substr($1, 1, 1) != \"-\") && ($3 < 10 || $1 == \"ftp\")) print $0}' /etc/master.passwd > %s/etc/master.passwd", tconf.homedir);
vsystem("/usr/sbin/pwd_mkdb -d %s/etc %s/etc/master.passwd && chmod 444 %s/etc/pwd.db", tconf.homedir, tconf.homedir, tconf.homedir);
vsystem("rm -f %s/etc/master.passwd %s/etc/spwd.db", tconf.homedir, tconf.homedir);
vsystem("awk -F: '{if ((substr($1, 1, 1) != \"+\") && (substr($1, 1, 1) != \"-\") && ($3 < 100)) print $0}' /etc/group > %s/etc/group && chmod 444 %s/etc/group", tconf.homedir, tconf.homedir);
vsystem("chown -R root.%s %s/pub", tconf.group, tconf.homedir);
}
else {