1995-10-19 17:15:43 +01:00
|
|
|
/*
|
|
|
|
* The new sysinstall program.
|
|
|
|
*
|
|
|
|
* This is probably the last program in the `sysinstall' line - the next
|
|
|
|
* generation being essentially a complete rewrite.
|
|
|
|
*
|
1997-02-22 15:13:04 +01:00
|
|
|
* $Id$
|
1995-10-19 17:15:43 +01:00
|
|
|
*
|
|
|
|
* Copyright (c) 1995
|
|
|
|
* Jordan Hubbard & Coranth Gryphon. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR THEIR PETS BE LIABLE
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sysinstall.h"
|
1995-11-03 13:02:45 +01:00
|
|
|
|
1995-10-19 17:15:43 +01:00
|
|
|
static DMenu MenuSamba = {
|
1996-04-29 20:06:08 +02:00
|
|
|
DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
|
1995-10-19 17:15:43 +01:00
|
|
|
"Samba Services Menu",
|
|
|
|
"This allows you to configure various aspects of your Samba server.",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
{ { "Homes", "Make home directories available to users.",
|
1996-04-07 05:52:36 +02:00
|
|
|
dmenuVarCheck, dmenuSetVariable, NULL, "SAMBA_homes=YES" },
|
1995-10-19 17:15:43 +01:00
|
|
|
{ "Printers", "Allows for sharing of local printers.",
|
1996-04-07 05:52:36 +02:00
|
|
|
dmenuVarCheck, dmenuSetVariable, NULL, "SAMBA_printers=YES" },
|
1995-10-19 17:15:43 +01:00
|
|
|
{ "Export Paths", "Specify local directories to make available.",
|
1996-04-07 05:52:36 +02:00
|
|
|
dmenuVarCheck, dmenuSetVariable, NULL, "SAMBA_export=YES" },
|
1995-10-19 17:15:43 +01:00
|
|
|
{ NULL } },
|
|
|
|
};
|
|
|
|
|
|
|
|
/* These probably shouldn't be hard-coded, but making them options might prove to be even more confusing! */
|
1996-07-26 10:39:06 +02:00
|
|
|
#define SMB_CONF_DIR "/usr/local/etc"
|
|
|
|
#define SMB_CONF "/usr/local/etc/smb.conf"
|
1995-10-19 17:15:43 +01:00
|
|
|
|
1995-11-03 13:02:45 +01:00
|
|
|
int
|
1996-04-07 05:52:36 +02:00
|
|
|
configSamba(dialogMenuItem *self)
|
1995-11-03 13:02:45 +01:00
|
|
|
{
|
1996-04-13 15:32:15 +02:00
|
|
|
int i = DITEM_SUCCESS;
|
1996-04-29 20:06:08 +02:00
|
|
|
WINDOW *w = savescr();
|
1995-11-03 13:02:45 +01:00
|
|
|
|
1996-07-02 03:03:55 +02:00
|
|
|
if (!dmenuOpenSimple(&MenuSamba, FALSE))
|
1996-04-13 15:32:15 +02:00
|
|
|
i = DITEM_FAILURE;
|
1997-01-20 17:13:43 +01:00
|
|
|
else if (DITEM_STATUS(package_add(variable_get(VAR_SAMBA_PKG))) != DITEM_SUCCESS)
|
1996-04-13 15:32:15 +02:00
|
|
|
i = DITEM_FAILURE;
|
1995-11-03 13:02:45 +01:00
|
|
|
else {
|
|
|
|
FILE *fptr;
|
|
|
|
char tbuf[256], *tptr;
|
|
|
|
int tval;
|
|
|
|
|
|
|
|
fptr = fopen("/tmp/smb.conf","w");
|
|
|
|
if (fptr) {
|
1996-04-28 05:27:26 +02:00
|
|
|
strcpy(tbuf, "FreeBSD - Samba %v");
|
1995-11-03 13:02:45 +01:00
|
|
|
if (variable_get("SAMBA_string")) {
|
|
|
|
tptr = msgGetInput("FreeBSD - Samba %%v", "What should this server list as its description?\n"
|
|
|
|
"Note that the \"%%v\" refers to the samba version number.");
|
|
|
|
if (tptr && *tptr)
|
|
|
|
strcpy(tbuf, tptr);
|
|
|
|
}
|
1995-10-19 17:15:43 +01:00
|
|
|
|
1995-11-03 13:02:45 +01:00
|
|
|
fprintf(fptr, "[global]\n");
|
|
|
|
fprintf(fptr, "comment = %s\n", tbuf);
|
|
|
|
fprintf(fptr, "log file = /var/log/samba.log\n");
|
|
|
|
fprintf(fptr, "dont descend = /dev,/proc,/root,/stand\n\n");
|
1995-10-19 17:15:43 +01:00
|
|
|
|
1995-11-03 13:02:45 +01:00
|
|
|
fprintf(fptr, "printing = bsd\n");
|
|
|
|
fprintf(fptr, "map archive = no\n");
|
|
|
|
fprintf(fptr, "status = yes\n");
|
|
|
|
fprintf(fptr, "public = yes\n");
|
|
|
|
fprintf(fptr, "read only = no\n");
|
|
|
|
fprintf(fptr, "preserve case = yes\n");
|
|
|
|
fprintf(fptr, "strip dot = yes\n");
|
|
|
|
fprintf(fptr, "security = share\n");
|
|
|
|
fprintf(fptr, "guest ok = yes\n\n");
|
1995-10-19 17:15:43 +01:00
|
|
|
|
1995-11-03 13:02:45 +01:00
|
|
|
if (variable_get("SAMBA_homes")) {
|
|
|
|
fprintf(fptr, "[homes]\n");
|
|
|
|
fprintf(fptr, "browseable = no\n");
|
|
|
|
fprintf(fptr, "comment = User Home Directory\n");
|
|
|
|
fprintf(fptr, "create mode = 0775\n");
|
|
|
|
fprintf(fptr, "public = no\n\n");
|
|
|
|
}
|
1995-10-19 17:15:43 +01:00
|
|
|
|
1995-11-03 13:02:45 +01:00
|
|
|
if (variable_get("SAMBA_printers")) {
|
|
|
|
fprintf(fptr, "[printers]\n");
|
|
|
|
fprintf(fptr, "path = /var/spool\n");
|
|
|
|
fprintf(fptr, "comment = Printers\n");
|
|
|
|
fprintf(fptr, "create mode = 0700\n");
|
|
|
|
fprintf(fptr, "browseable = no\n");
|
|
|
|
fprintf(fptr, "printable = yes\n");
|
|
|
|
fprintf(fptr, "read only = yes\n");
|
|
|
|
fprintf(fptr, "public = no\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (variable_get("SAMBA_export")) {
|
1996-08-03 12:11:56 +02:00
|
|
|
dialog_clear_norefresh();
|
1995-11-03 13:02:45 +01:00
|
|
|
for (tval = 0; ! tval; tval = msgYesNo("Another?")) {
|
|
|
|
tptr = msgGetInput(NULL,"What directory to export?");
|
|
|
|
if (tptr && *tptr && (tptr[0] == '/')) {
|
|
|
|
int len = strlen(tbuf);
|
|
|
|
|
|
|
|
strcpy(tbuf, tptr);
|
|
|
|
if (tbuf[len - 1] == '/')
|
|
|
|
tbuf[len - 1] = '\0';
|
1996-03-18 16:28:10 +01:00
|
|
|
if (directory_exists(tbuf)) {
|
1995-11-03 13:02:45 +01:00
|
|
|
tptr = msgGetInput(pathBaseName(tbuf), "What do you want to call this share?");
|
|
|
|
if (tptr && *tptr) {
|
|
|
|
fprintf(fptr, "[%s]\npath = %s\n", tptr, tbuf);
|
|
|
|
tptr = msgGetInput(NULL, "Enter a short description of this share?");
|
|
|
|
if (tptr && *tptr)
|
|
|
|
fprintf(fptr, "comment = %s\n", tptr);
|
1996-10-09 11:53:41 +02:00
|
|
|
if (msgYesNo("Do you want this share to be read only?") != 0)
|
1995-11-03 13:02:45 +01:00
|
|
|
fprintf(fptr, "read only = no\n\n");
|
|
|
|
else
|
|
|
|
fprintf(fptr, "read only = yes\n\n");
|
1995-10-19 17:15:43 +01:00
|
|
|
}
|
1996-04-23 03:29:35 +02:00
|
|
|
else
|
1995-11-03 13:02:45 +01:00
|
|
|
msgConfirm("Invalid Share Name.");
|
|
|
|
}
|
1996-04-23 03:29:35 +02:00
|
|
|
else
|
1995-11-03 13:02:45 +01:00
|
|
|
msgConfirm("Directory does not exist.");
|
|
|
|
} /* end if (tptr) */
|
|
|
|
} /* end for loop */
|
|
|
|
} /* end if (SAMBA_export) */
|
|
|
|
fclose(fptr);
|
1996-07-10 06:52:27 +02:00
|
|
|
Mkdir(SMB_CONF_DIR);
|
1995-11-03 13:02:45 +01:00
|
|
|
vsystem("mv -f /tmp/smb.conf %s", SMB_CONF);
|
|
|
|
}
|
1996-04-23 03:29:35 +02:00
|
|
|
else
|
1995-11-03 13:02:45 +01:00
|
|
|
msgConfirm("Unable to open temporary smb.conf file.\n"
|
|
|
|
"Samba will have to be configured by hand.");
|
1995-10-19 17:15:43 +01:00
|
|
|
}
|
1996-04-28 05:27:26 +02:00
|
|
|
if (DITEM_STATUS(i) == DITEM_SUCCESS)
|
|
|
|
variable_set2("samba", "YES");
|
1996-04-29 20:06:08 +02:00
|
|
|
restorescr(w);
|
1997-01-17 09:47:13 +01:00
|
|
|
return i | DITEM_RESTORE;
|
1995-11-03 13:02:45 +01:00
|
|
|
}
|