1995-11-09 02:32:05 +00:00
|
|
|
/*
|
|
|
|
* The new sysinstall program.
|
|
|
|
*
|
|
|
|
* This is probably the last program in the `sysinstall' line - the next
|
|
|
|
* generation being essentially a complete rewrite.
|
|
|
|
*
|
1999-08-28 01:35:59 +00:00
|
|
|
* $FreeBSD$
|
1995-11-09 02:32:05 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 1995
|
|
|
|
* Coranth Gryphon. All rights reserved.
|
1996-09-01 08:17:14 +00:00
|
|
|
* Copyright (c) 1996
|
|
|
|
* Jordan K. Hubbard. All rights reserved.
|
1995-11-09 02:32:05 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer,
|
|
|
|
* verbatim and that no modifications are made prior to this
|
|
|
|
* point in the file.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
1996-09-01 08:17:14 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND
|
1995-11-09 02:32:05 +00:00
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
1996-09-01 08:17:14 +00:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR THEIR PETS BE LIABLE
|
1995-11-09 02:32:05 +00:00
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1997-01-03 06:32:39 +00:00
|
|
|
#include "sysinstall.h"
|
1995-11-09 02:32:05 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <grp.h>
|
|
|
|
|
|
|
|
/* This doesn't change until FTP itself changes */
|
|
|
|
|
|
|
|
#define FTP_NAME "ftp"
|
1995-11-10 04:43:47 +00:00
|
|
|
#define MOTD_FILE "ftpmotd"
|
1995-11-09 02:32:05 +00:00
|
|
|
|
|
|
|
/* These change if we want to use different defaults */
|
|
|
|
|
|
|
|
#define FTP_UID 14
|
1995-11-10 04:43:47 +00:00
|
|
|
#define FTP_GID 5
|
1995-11-09 02:32:05 +00:00
|
|
|
#define FTP_GROUP "operator"
|
|
|
|
#define FTP_UPLOAD "incoming"
|
|
|
|
#define FTP_COMMENT "Anonymous FTP Admin"
|
1996-03-02 07:31:58 +00:00
|
|
|
#define FTP_HOMEDIR "/var/ftp"
|
1995-11-09 02:32:05 +00:00
|
|
|
|
|
|
|
#define ANONFTP_HELPFILE "anonftp"
|
|
|
|
|
|
|
|
/* Set up the structure to hold configuration information */
|
|
|
|
/* Note that this is only what we could fit onto the one screen */
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
1996-03-02 07:31:58 +00:00
|
|
|
char homedir[64]; /* Home Dir for Anon FTP */
|
1995-11-09 02:32:05 +00:00
|
|
|
char group[32]; /* Group */
|
|
|
|
char uid[8]; /* UID */
|
|
|
|
char comment[64]; /* PWD Comment */
|
|
|
|
char upload[32]; /* Upload Dir */
|
|
|
|
} FTPConf;
|
|
|
|
|
|
|
|
static FTPConf tconf;
|
|
|
|
|
|
|
|
#define ANONFTP_HOMEDIR_LEN 64
|
|
|
|
#define ANONFTP_COMMENT_LEN 64
|
|
|
|
#define ANONFTP_UPLOAD_LEN 32
|
|
|
|
#define ANONFTP_GROUP_LEN 32
|
|
|
|
#define ANONFTP_UID_LEN 8
|
|
|
|
|
|
|
|
static int okbutton, cancelbutton;
|
|
|
|
|
|
|
|
/* What the screen size is meant to be */
|
|
|
|
#define ANONFTP_DIALOG_Y 0
|
|
|
|
#define ANONFTP_DIALOG_X 8
|
|
|
|
#define ANONFTP_DIALOG_WIDTH COLS - 16
|
|
|
|
#define ANONFTP_DIALOG_HEIGHT LINES - 2
|
|
|
|
|
|
|
|
static Layout layout[] = {
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_UID 0
|
1996-03-02 07:31:58 +00:00
|
|
|
{ 2, 3, 8, ANONFTP_UID_LEN - 1,
|
1995-11-09 02:32:05 +00:00
|
|
|
"UID:", "What user ID to assign to FTP Admin",
|
|
|
|
tconf.uid, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_GROUP 1
|
1996-03-02 07:31:58 +00:00
|
|
|
{ 2, 15, 15, ANONFTP_GROUP_LEN - 1,
|
1995-11-09 02:32:05 +00:00
|
|
|
"Group:", "Group name that ftp process belongs to",
|
|
|
|
tconf.group, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_COMMENT 2
|
1996-03-02 07:31:58 +00:00
|
|
|
{ 2, 35, 24, ANONFTP_COMMENT_LEN - 1,
|
1995-11-09 02:32:05 +00:00
|
|
|
"Comment:", "Password file comment for FTP Admin",
|
|
|
|
tconf.comment, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_HOMEDIR 3
|
1996-03-02 07:31:58 +00:00
|
|
|
{ 9, 10, 43, ANONFTP_HOMEDIR_LEN - 1,
|
1995-11-09 02:32:05 +00:00
|
|
|
"FTP Root Directory:",
|
|
|
|
"The top directory to chroot to when doing anonymous ftp",
|
|
|
|
tconf.homedir, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_UPLOAD 4
|
1996-03-02 07:31:58 +00:00
|
|
|
{ 14, 20, 22, ANONFTP_UPLOAD_LEN - 1,
|
2004-11-16 19:06:42 +00:00
|
|
|
"Upload Subdirectory:", "Designated sub-directory that holds uploads (leave empty for none)",
|
1995-11-09 02:32:05 +00:00
|
|
|
tconf.upload, STRINGOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_OKBUTTON 5
|
1996-03-02 07:31:58 +00:00
|
|
|
{ 19, 15, 0, 0,
|
1995-11-09 02:32:05 +00:00
|
|
|
"OK", "Select this if you are happy with these settings",
|
|
|
|
&okbutton, BUTTONOBJ, NULL },
|
1997-01-03 06:32:39 +00:00
|
|
|
#define LAYOUT_CANCELBUTTON 6
|
1996-03-02 07:31:58 +00:00
|
|
|
{ 19, 35, 0, 0,
|
1995-11-09 02:32:05 +00:00
|
|
|
"CANCEL", "Select this if you wish to cancel this screen",
|
|
|
|
&cancelbutton, BUTTONOBJ, NULL },
|
2004-03-11 11:58:16 +00:00
|
|
|
{ 0 },
|
1995-11-09 02:32:05 +00:00
|
|
|
};
|
|
|
|
|
2001-09-22 22:21:01 +00:00
|
|
|
static int
|
1996-03-18 15:28:10 +00:00
|
|
|
createFtpUser(void)
|
1995-11-09 02:32:05 +00:00
|
|
|
{
|
1996-03-02 07:31:58 +00:00
|
|
|
struct passwd *tpw;
|
|
|
|
struct group *tgrp;
|
|
|
|
char pwline[256];
|
|
|
|
char *tptr;
|
|
|
|
int gid;
|
|
|
|
FILE *fptr;
|
|
|
|
|
|
|
|
if ((gid = atoi(tconf.group)) <= 0) {
|
|
|
|
if (!(tgrp = getgrnam(tconf.group))) {
|
|
|
|
/* group does not exist, create it by name */
|
|
|
|
|
|
|
|
tptr = msgGetInput("14", "What group ID to use for group %s ?", tconf.group);
|
|
|
|
if (tptr && *tptr && ((gid = atoi(tptr)) > 0)) {
|
|
|
|
if ((fptr = fopen(_PATH_GROUP,"a"))) {
|
|
|
|
fprintf(fptr,"%s:*:%d:%s\n",tconf.group,gid,FTP_NAME);
|
|
|
|
fclose(fptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gid = FTP_GID;
|
|
|
|
}
|
1995-11-09 02:32:05 +00:00
|
|
|
else
|
1996-03-02 07:31:58 +00:00
|
|
|
gid = tgrp->gr_gid;
|
1995-11-09 02:32:05 +00:00
|
|
|
}
|
1996-03-02 07:31:58 +00:00
|
|
|
else if (!getgrgid(gid)) {
|
1995-11-09 02:32:05 +00:00
|
|
|
/* group does not exist, create it by number */
|
1996-03-02 07:31:58 +00:00
|
|
|
|
1995-11-11 11:56:40 +00:00
|
|
|
tptr = msgGetInput("14", "What group name to use for gid %d ?", gid);
|
|
|
|
if (tptr && *tptr) {
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.group, tptr);
|
1996-03-02 07:31:58 +00:00
|
|
|
if ((tgrp = getgrnam(tconf.group))) {
|
|
|
|
gid = tgrp->gr_gid;
|
|
|
|
}
|
|
|
|
else if ((fptr = fopen(_PATH_GROUP,"a"))) {
|
|
|
|
fprintf(fptr,"%s:*:%d:%s\n",tconf.group,gid,FTP_NAME);
|
|
|
|
fclose(fptr);
|
|
|
|
}
|
1995-11-11 11:56:40 +00:00
|
|
|
}
|
1995-11-09 02:32:05 +00:00
|
|
|
}
|
1996-03-02 07:31:58 +00:00
|
|
|
|
|
|
|
if ((tpw = getpwnam(FTP_NAME))) {
|
|
|
|
if (tpw->pw_uid != FTP_UID)
|
|
|
|
msgConfirm("FTP user already exists with a different uid.");
|
|
|
|
|
1997-01-03 06:32:39 +00:00
|
|
|
return DITEM_SUCCESS; /* succeeds if already exists */
|
1995-11-09 02:32:05 +00:00
|
|
|
}
|
1996-03-02 07:31:58 +00:00
|
|
|
|
1997-04-02 12:07:39 +00:00
|
|
|
sprintf(pwline, "%s:*:%s:%d::0:0:%s:%s:/nonexistent\n", FTP_NAME, tconf.uid, gid, tconf.comment, tconf.homedir);
|
1996-03-02 07:31:58 +00:00
|
|
|
|
|
|
|
fptr = fopen(_PATH_MASTERPASSWD,"a");
|
|
|
|
if (! fptr) {
|
|
|
|
msgConfirm("Could not open master password file.");
|
1997-01-03 06:32:39 +00:00
|
|
|
return DITEM_FAILURE;
|
1996-03-02 07:31:58 +00:00
|
|
|
}
|
2001-07-05 09:51:09 +00:00
|
|
|
fprintf(fptr, "%s", pwline);
|
1996-03-02 07:31:58 +00:00
|
|
|
fclose(fptr);
|
|
|
|
msgNotify("Remaking password file: %s", _PATH_MASTERPASSWD);
|
|
|
|
vsystem("pwd_mkdb -p %s", _PATH_MASTERPASSWD);
|
1999-12-17 02:46:04 +00:00
|
|
|
return DITEM_SUCCESS | DITEM_RESTORE;
|
1995-11-09 02:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This is it - how to get the setup values */
|
1996-04-23 01:29:35 +00:00
|
|
|
static int
|
1996-03-18 15:28:10 +00:00
|
|
|
anonftpOpenDialog(void)
|
1995-11-09 02:32:05 +00:00
|
|
|
{
|
|
|
|
WINDOW *ds_win;
|
1997-01-03 06:32:39 +00:00
|
|
|
ComposeObj *obj = NULL;
|
|
|
|
int n = 0, cancel = FALSE;
|
1995-11-09 02:32:05 +00:00
|
|
|
int max;
|
|
|
|
char title[80];
|
1999-12-14 04:25:29 +00:00
|
|
|
WINDOW *w = savescr();
|
|
|
|
|
1995-11-09 02:32:05 +00:00
|
|
|
/* We need a curses window */
|
1997-01-03 06:32:39 +00:00
|
|
|
if (!(ds_win = openLayoutDialog(ANONFTP_HELPFILE, " Anonymous FTP Configuration ",
|
|
|
|
ANONFTP_DIALOG_X, ANONFTP_DIALOG_Y, ANONFTP_DIALOG_WIDTH, ANONFTP_DIALOG_HEIGHT))) {
|
1996-03-18 15:28:10 +00:00
|
|
|
beep();
|
|
|
|
msgConfirm("Cannot open anonymous ftp dialog window!!");
|
1999-12-14 04:25:29 +00:00
|
|
|
restorescr(w);
|
1997-01-03 06:32:39 +00:00
|
|
|
return DITEM_FAILURE;
|
1996-03-18 15:28:10 +00:00
|
|
|
}
|
1995-11-09 02:32:05 +00:00
|
|
|
|
1997-01-03 06:32:39 +00:00
|
|
|
/* Draw a sub-box for the path configuration */
|
|
|
|
draw_box(ds_win, ANONFTP_DIALOG_Y + 7, ANONFTP_DIALOG_X + 8,
|
|
|
|
ANONFTP_DIALOG_HEIGHT - 11, ANONFTP_DIALOG_WIDTH - 17,
|
1996-03-02 07:31:58 +00:00
|
|
|
dialog_attr, border_attr);
|
1995-11-09 02:32:05 +00:00
|
|
|
wattrset(ds_win, dialog_attr);
|
|
|
|
sprintf(title, " Path Configuration ");
|
|
|
|
mvwaddstr(ds_win, ANONFTP_DIALOG_Y + 7, ANONFTP_DIALOG_X + 22, title);
|
|
|
|
|
|
|
|
/** Initialize the config Data Structure **/
|
|
|
|
bzero(&tconf, sizeof(tconf));
|
|
|
|
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.group, FTP_GROUP);
|
|
|
|
SAFE_STRCPY(tconf.upload, FTP_UPLOAD);
|
|
|
|
SAFE_STRCPY(tconf.comment, FTP_COMMENT);
|
|
|
|
SAFE_STRCPY(tconf.homedir, FTP_HOMEDIR);
|
1995-11-09 02:32:05 +00:00
|
|
|
sprintf(tconf.uid, "%d", FTP_UID);
|
|
|
|
|
|
|
|
/* Some more initialisation before we go into the main input loop */
|
1997-01-03 06:32:39 +00:00
|
|
|
obj = initLayoutDialog(ds_win, layout, ANONFTP_DIALOG_X, ANONFTP_DIALOG_Y, &max);
|
|
|
|
|
|
|
|
cancelbutton = okbutton = 0;
|
|
|
|
while (layoutDialogLoop(ds_win, layout, &obj, &n, max, &cancelbutton, &cancel));
|
|
|
|
|
1995-11-09 02:32:05 +00:00
|
|
|
/* Clear this crap off the screen */
|
1997-03-09 22:25:49 +00:00
|
|
|
delwin(ds_win);
|
1995-11-09 02:32:05 +00:00
|
|
|
use_helpfile(NULL);
|
1999-12-14 04:25:29 +00:00
|
|
|
restorescr(w);
|
1995-11-09 02:32:05 +00:00
|
|
|
if (cancel)
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
|
|
|
return DITEM_SUCCESS;
|
1995-11-09 02:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-22 22:21:01 +00:00
|
|
|
configAnonFTP(dialogMenuItem *self __unused)
|
1995-11-09 02:32:05 +00:00
|
|
|
{
|
|
|
|
int i;
|
Compensate for default disabling of network services in inetd.conf(5)
by providing the opportunity to edit inetd.conf during the system
installation process. The following modifications were made:
(1) Expand the Anonymous FTP description dialog to indicate that inetd
and ftpd must be enabled before it can be used.
(2) Introduce a new configInetd() pair of dialogs, the first describing
inetd, giving a couple of examples of services that require it, and
hinting at potential risk, then asking the user if they wish to
enable it. The second indicates that inetd.conf must be configured
to enabled specific services, and asks if the user would like to
load inetd.conf into the editor to modify it. Add this
configuration action to the index.
There are some further improvements that might be considered:
(1) Provide a more inetd.conf-specific configuration tool that speaks
inetd.conf(5). However, this is made difficult by the "yet another
configuration format" nature of inetd.conf, as well as its use of
commenting to disable services, rather than an in-syntax way to
disable a service without commenting it out. Submissions here
would probably be welcome.
(2) There's some overlap between settings in the somewhat obtuse
Security Profile mechanism and other settings, including the inetd
setting, and NFS server configuration. As features become
individually tunable, they should probably be removed from the
security profile mechanism. Otherwise, somewhat counter-intuitively,
sysinstall (in practice) queries multiple times whether inetd, nfsd,
etc, should be enabled/disabled. A possible future direction might
be to drive profiles not by degree of paranoia, rather, the set
of services desired. Or simply to remove the Security Profile
mechanism and resort to feature-driven configuration.
Reviewed by: imp, chris, jake, nate, -arch, -stable
2001-08-02 03:25:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (msgYesNo("Anonymous FTP permits un-authenticated users to connect to the system\n"
|
|
|
|
"FTP server, if FTP service is enabled. Anonymous users are\n"
|
|
|
|
"restricted to a specific subset of the file system, and the default\n"
|
|
|
|
"configuration provides a drop-box incoming directory to which uploads\n"
|
2002-08-06 20:36:02 +00:00
|
|
|
"are permitted. You must separately enable both inetd(8), and enable\n"
|
Compensate for default disabling of network services in inetd.conf(5)
by providing the opportunity to edit inetd.conf during the system
installation process. The following modifications were made:
(1) Expand the Anonymous FTP description dialog to indicate that inetd
and ftpd must be enabled before it can be used.
(2) Introduce a new configInetd() pair of dialogs, the first describing
inetd, giving a couple of examples of services that require it, and
hinting at potential risk, then asking the user if they wish to
enable it. The second indicates that inetd.conf must be configured
to enabled specific services, and asks if the user would like to
load inetd.conf into the editor to modify it. Add this
configuration action to the index.
There are some further improvements that might be considered:
(1) Provide a more inetd.conf-specific configuration tool that speaks
inetd.conf(5). However, this is made difficult by the "yet another
configuration format" nature of inetd.conf, as well as its use of
commenting to disable services, rather than an in-syntax way to
disable a service without commenting it out. Submissions here
would probably be welcome.
(2) There's some overlap between settings in the somewhat obtuse
Security Profile mechanism and other settings, including the inetd
setting, and NFS server configuration. As features become
individually tunable, they should probably be removed from the
security profile mechanism. Otherwise, somewhat counter-intuitively,
sysinstall (in practice) queries multiple times whether inetd, nfsd,
etc, should be enabled/disabled. A possible future direction might
be to drive profiles not by degree of paranoia, rather, the set
of services desired. Or simply to remove the Security Profile
mechanism and resort to feature-driven configuration.
Reviewed by: imp, chris, jake, nate, -arch, -stable
2001-08-02 03:25:16 +00:00
|
|
|
"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"
|
2004-11-16 19:06:42 +00:00
|
|
|
"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"
|
Compensate for default disabling of network services in inetd.conf(5)
by providing the opportunity to edit inetd.conf during the system
installation process. The following modifications were made:
(1) Expand the Anonymous FTP description dialog to indicate that inetd
and ftpd must be enabled before it can be used.
(2) Introduce a new configInetd() pair of dialogs, the first describing
inetd, giving a couple of examples of services that require it, and
hinting at potential risk, then asking the user if they wish to
enable it. The second indicates that inetd.conf must be configured
to enabled specific services, and asks if the user would like to
load inetd.conf into the editor to modify it. Add this
configuration action to the index.
There are some further improvements that might be considered:
(1) Provide a more inetd.conf-specific configuration tool that speaks
inetd.conf(5). However, this is made difficult by the "yet another
configuration format" nature of inetd.conf, as well as its use of
commenting to disable services, rather than an in-syntax way to
disable a service without commenting it out. Submissions here
would probably be welcome.
(2) There's some overlap between settings in the somewhat obtuse
Security Profile mechanism and other settings, including the inetd
setting, and NFS server configuration. As features become
individually tunable, they should probably be removed from the
security profile mechanism. Otherwise, somewhat counter-intuitively,
sysinstall (in practice) queries multiple times whether inetd, nfsd,
etc, should be enabled/disabled. A possible future direction might
be to drive profiles not by degree of paranoia, rather, the set
of services desired. Or simply to remove the Security Profile
mechanism and resort to feature-driven configuration.
Reviewed by: imp, chris, jake, nate, -arch, -stable
2001-08-02 03:25:16 +00:00
|
|
|
"Do you wish to continue configuring anonymous FTP?")) {
|
|
|
|
return DITEM_FAILURE;
|
|
|
|
}
|
1996-03-02 07:31:58 +00:00
|
|
|
|
1995-11-09 02:32:05 +00:00
|
|
|
/* Be optimistic */
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_SUCCESS;
|
1996-03-02 07:31:58 +00:00
|
|
|
|
1995-11-09 02:32:05 +00:00
|
|
|
i = anonftpOpenDialog();
|
1996-04-28 03:27:26 +00:00
|
|
|
if (DITEM_STATUS(i) != DITEM_SUCCESS) {
|
1995-11-11 11:56:40 +00:00
|
|
|
msgConfirm("Configuration of Anonymous FTP cancelled per user request.");
|
1999-12-14 04:25:29 +00:00
|
|
|
return i;
|
1995-11-09 02:32:05 +00:00
|
|
|
}
|
1996-03-02 07:31:58 +00:00
|
|
|
|
1995-11-11 11:56:40 +00:00
|
|
|
/*** Use defaults for any invalid values ***/
|
1995-11-09 02:32:05 +00:00
|
|
|
if (atoi(tconf.uid) <= 0)
|
|
|
|
sprintf(tconf.uid, "%d", FTP_UID);
|
|
|
|
|
1995-11-11 11:56:40 +00:00
|
|
|
if (!tconf.group[0])
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.group, FTP_GROUP);
|
1995-11-09 02:32:05 +00:00
|
|
|
|
|
|
|
/*** If the user did not specify a directory, use default ***/
|
|
|
|
|
1996-04-28 03:27:26 +00:00
|
|
|
if (tconf.homedir[strlen(tconf.homedir) - 1] == '/')
|
|
|
|
tconf.homedir[strlen(tconf.homedir) - 1] = '\0';
|
1995-11-09 02:32:05 +00:00
|
|
|
|
|
|
|
if (!tconf.homedir[0])
|
1996-12-09 08:22:19 +00:00
|
|
|
SAFE_STRCPY(tconf.homedir, FTP_HOMEDIR);
|
1995-11-09 02:32:05 +00:00
|
|
|
|
|
|
|
/*** If HomeDir does not exist, create it ***/
|
|
|
|
|
1996-04-28 01:07:27 +00:00
|
|
|
if (!directory_exists(tconf.homedir))
|
1996-04-23 01:29:35 +00:00
|
|
|
vsystem("mkdir -p %s", tconf.homedir);
|
1996-03-02 07:31:58 +00:00
|
|
|
|
1996-03-18 15:28:10 +00:00
|
|
|
if (directory_exists(tconf.homedir)) {
|
1996-03-02 07:31:58 +00:00
|
|
|
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/etc && chmod 555 %s/etc", tconf.homedir, tconf.homedir);
|
|
|
|
vsystem("mkdir -p %s/pub", tconf.homedir);
|
2004-11-16 19:06:42 +00:00
|
|
|
if (tconf.upload[0]) {
|
|
|
|
vsystem("mkdir -p %s/%s", tconf.homedir, tconf.upload);
|
|
|
|
vsystem("chmod 1777 %s/%s", tconf.homedir, tconf.upload);
|
|
|
|
}
|
1996-03-02 07:31:58 +00:00
|
|
|
|
1996-04-28 03:27:26 +00:00
|
|
|
if (DITEM_STATUS(createFtpUser()) == DITEM_SUCCESS) {
|
1996-03-02 07:31:58 +00:00
|
|
|
msgNotify("Copying password information for anon FTP.");
|
2004-11-16 19:06:42 +00:00
|
|
|
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);
|
1996-09-06 05:58:27 +00:00
|
|
|
vsystem("chown -R root.%s %s/pub", tconf.group, tconf.homedir);
|
1996-03-02 07:31:58 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
msgConfirm("Unable to create FTP user! Anonymous FTP setup failed.");
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_FAILURE;
|
1996-03-02 07:31:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!msgYesNo("Create a welcome message file for anonymous FTP users?")) {
|
|
|
|
char cmd[256];
|
|
|
|
vsystem("echo Your welcome message here. > %s/etc/%s", tconf.homedir, MOTD_FILE);
|
1996-03-23 07:21:31 +00:00
|
|
|
sprintf(cmd, "%s %s/etc/%s", variable_get(VAR_EDITOR), tconf.homedir, MOTD_FILE);
|
1996-04-13 13:32:15 +00:00
|
|
|
if (!systemExecute(cmd))
|
|
|
|
i = DITEM_SUCCESS;
|
|
|
|
else
|
|
|
|
i = DITEM_FAILURE;
|
1996-03-02 07:31:58 +00:00
|
|
|
}
|
1995-11-11 11:56:40 +00:00
|
|
|
}
|
1996-03-02 07:31:58 +00:00
|
|
|
else {
|
1995-11-11 11:56:40 +00:00
|
|
|
msgConfirm("Invalid Directory: %s\n"
|
|
|
|
"Anonymous FTP will not be set up.", tconf.homedir);
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_FAILURE;
|
1996-03-02 07:31:58 +00:00
|
|
|
}
|
1996-04-28 03:27:26 +00:00
|
|
|
if (DITEM_STATUS(i) == DITEM_SUCCESS)
|
1999-02-05 22:15:52 +00:00
|
|
|
variable_set2("anon_ftp", "YES", 0);
|
1999-12-17 02:46:04 +00:00
|
|
|
return i | DITEM_RESTORE;
|
1995-11-09 02:32:05 +00:00
|
|
|
}
|