diff options
Diffstat (limited to 'source/web/swat.c')
-rw-r--r-- | source/web/swat.c | 827 |
1 files changed, 415 insertions, 412 deletions
diff --git a/source/web/swat.c b/source/web/swat.c index af6fa82ffe5..c5c211672ed 100644 --- a/source/web/swat.c +++ b/source/web/swat.c @@ -1,7 +1,7 @@ /* - Unix SMB/CIFS implementation. + Unix SMB/Netbios implementation. + Version 2.2.6 Samba Web Administration Tool - Version 3.0.0 Copyright (C) Andrew Tridgell 1997-2002 Copyright (C) John H Terpstra 2002 @@ -20,19 +20,16 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/** - * @group swat SWAT - * @{ - * @file swat.c - * - * @brief Samba Web Administration Tool. - **/ +#ifdef SYSLOG +#undef SYSLOG +#endif #include "includes.h" -#include "../web/swat_proto.h" +#include "smb.h" #define GLOBALS_SNUM -1 +static pstring servicesf = CONFIGFILE; static BOOL demo_mode = False; static BOOL have_write_access = False; static BOOL have_read_access = False; @@ -53,6 +50,19 @@ static int iNumNonAutoPrintServices = 0; #define ENABLE_USER_FLAG "enable_user_flag" #define RHOST "remote_host" +typedef struct html_conversion { + char src; + char *dest; +} html_conversion; + +static const html_conversion entities[] = { + { '"', """ }, + { '&', "&" }, + { '<', "<" }, + { '>', ">" }, + { '\0', NULL }, +}; + /* we need these because we link to locking*.o */ void become_root(void) {} void unbecome_root(void) {} @@ -81,15 +91,60 @@ static char *fix_backslash(char *str) return newstring; } -static char *stripspaceupper(char *str) +static char *htmlentities(char *str) { - static char newstring[1024]; - char *p = newstring; + int i,j, destlen = 0; + int length = strlen(str); + /* Feel free to use a pstring if appropriate -- I haven't + checked if it's guaranteed to be long enough, and suspect it + isn't. -SRL */ + char *dststr = NULL; + char *p; - while (*str) { - if (*str != ' ') *p++ = toupper(*str); - ++str; + for (i = 0; i < length; i++) { + for (j = 0; entities[j].src; j++) { + if (str[i] == entities[j].src) { + destlen += strlen(entities[j].dest); + break; + } + } + if (!entities[j].src) { + destlen++; + } + } + if (length == destlen) { + return(strdup(str)); + } + p = dststr = malloc(destlen + 1); + if (!dststr) { + return(NULL); } + dststr[destlen] = '\0'; + for (i = 0; i < length; i++) { + for (j = 0; entities[j].src; j++) { + if (str[i] == entities[j].src) { + strncpy(p, entities[j].dest, + strlen(entities[j].dest)); + p += strlen(entities[j].dest); + break; + } + } + if (!entities[j].src) { + *p++ = str[i]; + } + } + return(dststr); +} + +static char *stripspace(char *str) +{ +static char newstring[1024]; +char *p = newstring; + + while (*str) { + if (*str != ' ') *p++ = *str; + ++str; + } *p = '\0'; return newstring; } @@ -113,22 +168,22 @@ static char *make_parm_name(char *label) ****************************************************************************/ static int include_html(char *fname) { - int fd; + FILE *f = sys_fopen(fname,"r"); char buf[1024]; int ret; - fd = web_open(fname, O_RDONLY, 0); - - if (fd == -1) { - d_printf("ERROR: Can't open %s\n", fname); + if (!f) { + printf("ERROR: Can't open %s\n", fname); return 0; } - while ((ret = read(fd, buf, sizeof(buf))) > 0) { - write(1, buf, ret); + while (!feof(f)) { + ret = fread(buf, 1, sizeof(buf), f); + if (ret <= 0) break; + fwrite(buf, 1, ret, stdout); } - close(fd); + fclose(f); return 1; } @@ -138,55 +193,23 @@ static int include_html(char *fname) static void print_header(void) { if (!cgi_waspost()) { - d_printf("Expires: 0\r\n"); + printf("Expires: 0\r\n"); } - d_printf("Content-type: text/html\r\n\r\n"); + printf("Content-type: text/html\r\n\r\n"); if (!include_html("include/header.html")) { - d_printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"); - d_printf("<HTML>\n<HEAD>\n<TITLE>Samba Web Administration Tool</TITLE>\n</HEAD>\n<BODY background=\"/swat/images/background.jpg\">\n\n"); + printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"); + printf("<HTML>\n<HEAD>\n<TITLE>Samba Web Administration Tool</TITLE>\n</HEAD>\n<BODY background=\"/swat/images/background.jpg\">\n\n"); } } -/* ******************************************************************* - show parameter label with translated name in the following form - because showing original and translated label in one line looks - too long, and showing translated label only is unusable for - heavy users. - ------------------------------- - HELP security [combo box][button] - SECURITY - ------------------------------- - (capital words are translated by gettext.) - if no translation is available, then same form as original is - used. - "i18n_translated_parm" class is used to change the color of the - translated parameter with CSS. - **************************************************************** */ -static const char* get_parm_translated( - const char* pAnchor, const char* pHelp, const char* pLabel) -{ - const char* pTranslated = _(pLabel); - static pstring output; - if(strcmp(pLabel, pTranslated) != 0) - { - snprintf(output, sizeof(output), - "<A HREF=\"/swat/help/smb.conf.5.html#%s\" target=\"docs\"> %s</A> %s <br><span class=\"i18n_translated_parm\">%s</span>", - pAnchor, pHelp, pLabel, pTranslated); - return output; - } - snprintf(output, sizeof(output), - "<A HREF=\"/swat/help/smb.conf.5.html#%s\" target=\"docs\"> %s</A> %s", - pAnchor, pHelp, pLabel); - return output; -} /**************************************************************************** finish off the page ****************************************************************************/ static void print_footer(void) { if (!include_html("include/footer.html")) { - d_printf("\n</BODY>\n</HTML>\n"); + printf("\n</BODY>\n</HTML>\n"); } } @@ -197,103 +220,102 @@ static void show_parameter(int snum, struct parm_struct *parm) { int i; void *ptr = parm->ptr; + char* str; if (parm->class == P_LOCAL && snum >= 0) { ptr = lp_local_ptr(snum, ptr); } - printf("<tr><td>%s</td><td>", get_parm_translated(stripspaceupper(parm->label), _("Help"), parm->label)); + str = stripspace(parm->label); + strupper (str); + printf("<tr><td><A HREF=\"/swat/help/smb.conf.5.html#%s\" target=\"docs\">Help</A> %s</td><td>", + str, parm->label); + switch (parm->type) { case P_CHAR: - d_printf("<input type=text size=2 name=\"parm_%s\" value=\"%c\">", + printf("<input type=text size=2 name=\"parm_%s\" value=\"%c\">", make_parm_name(parm->label), *(char *)ptr); - d_printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%c\'\">", - _("Set Default"), make_parm_name(parm->label),(char)(parm->def.cvalue)); - break; - - case P_LIST: - d_printf("<input type=text size=40 name=\"parm_%s\" value=\"", - make_parm_name(parm->label)); - if ((char ***)ptr && *(char ***)ptr && **(char ***)ptr) { - char **list = *(char ***)ptr; - for (;*list;list++) { - d_printf("%s%s", *list, ((*(list+1))?" ":"")); - } - } - d_printf("\">"); - d_printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'", - _("Set Default"), make_parm_name(parm->label)); - if (parm->def.lvalue) { - char **list = (char **)(parm->def.lvalue); - for (; *list; list++) { - d_printf("%s%s", *list, ((*(list+1))?" ":"")); - } - } - d_printf("\'\">"); + printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.value=\'%c\'\">", + make_parm_name(parm->label),(char)(parm->def.cvalue)); break; case P_STRING: case P_USTRING: - d_printf("<input type=text size=40 name=\"parm_%s\" value=\"%s\">", - make_parm_name(parm->label), *(char **)ptr); - d_printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%s\'\">", - _("Set Default"), make_parm_name(parm->label),fix_backslash((char *)(parm->def.svalue))); + str = htmlentities(*(char **)ptr); + printf("<input type=\"text\" size=\"40\" name=\"parm_%s\" value=\"%s\">", + make_parm_name(parm->label), str); + if (str != NULL) { + free(str); + } + printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.value=\'%s\'\">", + make_parm_name(parm->label),fix_backslash((char *)(parm->def.svalue))); break; case P_GSTRING: case P_UGSTRING: - d_printf("<input type=text size=40 name=\"parm_%s\" value=\"%s\">", + printf("<input type=text size=40 name=\"parm_%s\" value=\"%s\">", make_parm_name(parm->label), (char *)ptr); - d_printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%s\'\">", - _("Set Default"), make_parm_name(parm->label),fix_backslash((char *)(parm->def.svalue))); + printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.value=\'%s\'\">", + make_parm_name(parm->label),fix_backslash((char *)(parm->def.svalue))); break; case P_BOOL: - d_printf("<select name=\"parm_%s\">",make_parm_name(parm->label)); - d_printf("<option %s>Yes", (*(BOOL *)ptr)?"selected":""); - d_printf("<option %s>No", (*(BOOL *)ptr)?"":"selected"); - d_printf("</select>"); - d_printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.selectedIndex=\'%d\'\">", - _("Set Default"), make_parm_name(parm->label),(BOOL)(parm->def.bvalue)?0:1); + printf("<select name=\"parm_%s\">",make_parm_name(parm->label)); + printf("<option %s>Yes", (*(BOOL *)ptr)?"selected":""); + printf("<option %s>No", (*(BOOL *)ptr)?"":"selected"); + printf("</select>"); + printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.selectedIndex=\'%d\'\">", + make_parm_name(parm->label),(BOOL)(parm->def.bvalue)?0:1); break; case P_BOOLREV: - d_printf("<select name=\"parm_%s\">",make_parm_name(parm->label)); - d_printf("<option %s>Yes", (*(BOOL *)ptr)?"":"selected"); - d_printf("<option %s>No", (*(BOOL *)ptr)?"selected":""); - d_printf("</select>"); - d_printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.selectedIndex=\'%d\'\">", - _("Set Default"), make_parm_name(parm->label),(BOOL)(parm->def.bvalue)?1:0); + printf("<select name=\"parm_%s\">",make_parm_name(parm->label)); + printf("<option %s>Yes", (*(BOOL *)ptr)?"":"selected"); + printf("<option %s>No", (*(BOOL *)ptr)?"selected":""); + printf("</select>"); + printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.selectedIndex=\'%d\'\">", + make_parm_name(parm->label),(BOOL)(parm->def.bvalue)?1:0); break; case P_INTEGER: - d_printf("<input type=text size=8 name=\"parm_%s\" value=%d>", make_parm_name(parm->label), *(int *)ptr); - d_printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%d\'\">", - _("Set Default"), make_parm_name(parm->label),(int)(parm->def.ivalue)); + if (strequal(parm->label,"log level")) { + printf("<input type=text size=40 name=\"parm_%s\" value=%d", + make_parm_name(parm->label),*(int *)ptr); + for (i = 1; i < DBGC_LAST; i ++) { + if (((int *)ptr)[i]) + printf(",%s:%d",debug_classname_from_index(i),((int *)ptr)[i]); + } + printf(">"); + } else { + printf("<input type=text size=8 name=\"parm_%s\" value=%d>", + make_parm_name(parm->label), *(int *)ptr); + } + printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.value=\'%d\'\">", + make_parm_name(parm->label),(int)(parm->def.ivalue)); break; case P_OCTAL: - d_printf("<input type=text size=8 name=\"parm_%s\" value=%s>", make_parm_name(parm->label), octal_string(*(int *)ptr)); - d_printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%s\'\">", - _("Set Default"), make_parm_name(parm->label), + printf("<input type=text size=8 name=\"parm_%s\" value=%s>", make_parm_name(parm->label), octal_string(*(int *)ptr)); + printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.value=\'%s\'\">", + make_parm_name(parm->label), octal_string((int)(parm->def.ivalue))); break; case P_ENUM: - d_printf("<select name=\"parm_%s\">",make_parm_name(parm->label)); + printf("<select name=\"parm_%s\">",make_parm_name(parm->label)); for (i=0;parm->enum_list[i].name;i++) { if (i == 0 || parm->enum_list[i].value != parm->enum_list[i-1].value) { - d_printf("<option %s>%s",(*(int *)ptr)==parm->enum_list[i].value?"selected":"",parm->enum_list[i].name); + printf("<option %s>%s",(*(int *)ptr)==parm->enum_list[i].value?"selected":"",parm->enum_list[i].name); } } - d_printf("</select>"); - d_printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.selectedIndex=\'%d\'\">", - _("Set Default"), make_parm_name(parm->label),enum_index((int)(parm->def.ivalue),parm->enum_list)); + printf("</select>"); + printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.selectedIndex=\'%d\'\">", + make_parm_name(parm->label),enum_index((int)(parm->def.ivalue),parm->enum_list)); break; case P_SEP: break; } - d_printf("</td></tr>\n"); + printf("</td></tr>\n"); } /**************************************************************************** @@ -331,10 +353,6 @@ static void show_parameters(int snum, int allparameters, unsigned int parm_filte if (*(char *)ptr == (char)(parm->def.cvalue)) continue; break; - case P_LIST: - if (!str_list_compare(*(char ***)ptr, (char **)(parm->def.lvalue))) continue; - break; - case P_STRING: case P_USTRING: if (!strcmp(*(char **)ptr,(char *)(parm->def.svalue))) continue; @@ -352,6 +370,8 @@ static void show_parameters(int snum, int allparameters, unsigned int parm_filte case P_INTEGER: case P_OCTAL: + if (strequal(parm->label,"log level")) + break; if (*(int *)ptr == (int)(parm->def.ivalue)) continue; break; @@ -368,11 +388,8 @@ static void show_parameters(int snum, int allparameters, unsigned int parm_filte if (parm_filter == FLAG_WIZARD) { if (!((parm->flags & FLAG_WIZARD))) continue; } - if (parm_filter == FLAG_ADVANCED) { - if (!((parm->flags & FLAG_ADVANCED))) continue; - } if (heading && heading != last_heading) { - d_printf("<tr><td></td></tr><tr><td><b><u>%s</u></b></td></tr>\n", _(heading)); + printf("<tr><td></td></tr><tr><td><b><u>%s</u></b></td></tr>\n", heading); last_heading = heading; } show_parameter(snum, parm); @@ -385,19 +402,20 @@ static void show_parameters(int snum, int allparameters, unsigned int parm_filte static BOOL load_config(BOOL save_def) { lp_resetnumservices(); - return lp_load(dyn_CONFIGFILE,False,save_def,False); + return lp_load(servicesf,False,save_def,False); } /**************************************************************************** write a config file ****************************************************************************/ -static void write_config(FILE *f, BOOL show_defaults) + +static void write_config(FILE *f, BOOL show_defaults, char *(*dos_to_ext)(const char *)) { fprintf(f, "# Samba config file created using SWAT\n"); fprintf(f, "# from %s (%s)\n", cgi_remote_host(), cgi_remote_addr()); fprintf(f, "# Date: %s\n\n", timestring(False)); - lp_dump(f, show_defaults, iNumNonAutoPrintServices); + lp_dump(f, show_defaults, iNumNonAutoPrintServices, dos_to_ext); } /**************************************************************************** @@ -408,9 +426,9 @@ static int save_reload(int snum) FILE *f; struct stat st; - f = sys_fopen(dyn_CONFIGFILE,"w"); + f = sys_fopen(servicesf,"w"); if (!f) { - d_printf("failed to open %s for writing\n", dyn_CONFIGFILE); + printf("failed to open %s for writing\n", servicesf); return 0; } @@ -420,15 +438,15 @@ static int save_reload(int snum) fchmod(fileno(f), S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); } - write_config(f, False); + write_config(f, False, _dos_to_unix_static); if (snum) - lp_dump_one(f, False, snum); + lp_dump_one(f, False, snum, _dos_to_unix_static); fclose(f); lp_killunused(NULL); if (!load_config(False)) { - d_printf("Can't reload %s\n", dyn_CONFIGFILE); + printf("Can't reload %s\n", servicesf); return 0; } iNumNonAutoPrintServices = lp_numservices(); @@ -445,6 +463,10 @@ static void commit_parameter(int snum, struct parm_struct *parm, char *v) int i; char *s; + /* lp_do_parameter() will do unix_to_dos(v). */ + if(parm->flags & FLAG_DOS_STRING) + dos_to_unix(v); + if (snum < 0 && parm->class == P_LOCAL) { /* this handles the case where we are changing a local variable globally. We need to change the parameter in @@ -482,9 +504,9 @@ static void commit_parameters(int snum) /**************************************************************************** spit out the html for a link with an image ****************************************************************************/ -static void image_link(const char *name, const char *hlink, const char *src) +static void image_link(char *name,char *hlink, char *src) { - d_printf("<A HREF=\"%s/%s\"><img border=\"0\" src=\"/swat/%s\" alt=\"%s\"></A>\n", + printf("<A HREF=\"%s/%s\"><img border=\"0\" src=\"/swat/%s\" alt=\"%s\"></A>\n", cgi_baseurl(), hlink, src, name); } @@ -497,35 +519,23 @@ static void show_main_buttons(void) char *p; if ((p = cgi_user_name()) && strcmp(p, "root")) { - d_printf(_("Logged in as <b>%s</b><p>\n"), p); + printf("Logged in as <b>%s</b><p>\n", p); } - image_link(_("Home"), "", "images/home.gif"); + image_link("Home", "", "images/home.gif"); if (have_write_access) { - image_link(_("Globals"), "globals", "images/globals.gif"); - image_link(_("Shares"), "shares", "images/shares.gif"); - image_link(_("Printers"), "printers", "images/printers.gif"); - image_link(_("Wizard"), "wizard", "images/wizard.gif"); + image_link("Globals", "globals", "images/globals.gif"); + image_link("Shares", "shares", "images/shares.gif"); + image_link("Printers", "printers", "images/printers.gif"); + image_link("Wizard", "wizard", "images/wizard.gif"); } if (have_read_access) { - image_link(_("Status"), "status", "images/status.gif"); - image_link(_("View Config"), "viewconfig", "images/viewconfig.gif"); + image_link("Status", "status", "images/status.gif"); + image_link("View Config", "viewconfig","images/viewconfig.gif"); } - image_link(_("Password Management"), "passwd", "images/passwd.gif"); + image_link("Password Management", "passwd", "images/passwd.gif"); - d_printf("<HR>\n"); -} - -/**************************************************************************** - * Handle Display/Edit Mode CGI - ****************************************************************************/ -static void ViewModeBoxes(int mode) -{ - d_printf("<p>%s\n", _("Configuration View: ")); - d_printf("<input type=radio name=\"ViewMode\" value=0 %s>Basic\n", (mode == 0) ? "checked" : ""); - d_printf("<input type=radio name=\"ViewMode\" value=1 %s>Advanced\n", (mode == 1) ? "checked" : ""); - d_printf("<input type=radio name=\"ViewMode\" value=2 %s>Developer\n", (mode == 2) ? "checked" : ""); - d_printf("</p><br>\n"); + printf("<HR>\n"); } /**************************************************************************** @@ -547,19 +557,19 @@ static void viewconfig_page(void) full_view = 1; } - d_printf("<H2>%s</H2>\n", _("Current Config")); - d_printf("<form method=post>\n"); + printf("<H2>Current Config</H2>\n"); + printf("<form method=post>\n"); if (full_view) { - d_printf("<input type=submit name=\"normal_view\" value=\"%s\">\n", _("Normal View")); + printf("<input type=submit name=\"normal_view\" value=\"Normal View\">\n"); } else { - d_printf("<input type=submit name=\"full_view\" value=\"%s\">\n", _("Full View")); + printf("<input type=submit name=\"full_view\" value=\"Full View\">\n"); } - d_printf("<p><pre>"); - write_config(stdout, full_view); - d_printf("</pre>"); - d_printf("</form>\n"); + printf("<p><pre>"); + write_config(stdout, full_view, _dos_to_dos_static); + printf("</pre>"); + printf("</form>\n"); } /**************************************************************************** @@ -572,26 +582,26 @@ static void wizard_params_page(void) /* Here we first set and commit all the parameters that were selected in the previous screen. */ - d_printf("<H2>Wizard Parameter Edit Page</H2>\n"); + printf("<H2>Wizard Parameter Edit Page ...</H2>\n"); if (cgi_variable("Commit")) { commit_parameters(GLOBALS_SNUM); save_reload(0); } - d_printf("<form name=\"swatform\" method=post action=wizard_params>\n"); + printf("<form name=\"swatform\" method=post action=wizard_params>\n"); if (have_write_access) { - d_printf("<input type=submit name=\"Commit\" value=\"Commit Changes\">\n"); + printf("<input type=submit name=\"Commit\" value=\"Commit Changes\">\n"); } - d_printf("<input type=reset name=\"Reset Values\" value=\"Reset\">\n"); - d_printf("<p>\n"); + printf("<input type=reset name=\"Reset Values\" value=\"Reset\">\n"); + printf("<p>\n"); - d_printf("<table>\n"); + printf("<table>\n"); show_parameters(GLOBALS_SNUM, 1, parm_filter, 0); - d_printf("</table>\n"); - d_printf("</form>\n"); + printf("</table>\n"); + printf("</form>\n"); } /**************************************************************************** @@ -601,7 +611,7 @@ static void rewritecfg_file(void) { commit_parameters(GLOBALS_SNUM); save_reload(0); - d_printf("<H2>Note: smb.conf %s</H2>\n", _("file has been read and rewritten")); + printf("<H2>Note: smb.conf file has been read and rewritten</H2>\n"); } /**************************************************************************** @@ -671,7 +681,7 @@ static void wizard_page(void) if ((HomeExpo == 1) && (have_home == -1)) { pstring unix_share; - pstrcpy(unix_share,HOMES_NAME); + pstrcpy(unix_share, dos_to_unix_static(HOMES_NAME)); load_config(False); lp_copy_service(GLOBALS_SNUM, unix_share); iNumNonAutoPrintServices = lp_numservices(); @@ -696,9 +706,8 @@ static void wizard_page(void) /* Now determine smb.conf WINS settings */ if (lp_wins_support()) winstype = 1; -/* if (strlen(lp_wins_server_list()) != 0 ) - * winstype = 2; - */ + if (strlen(lp_wins_server()) != 0 ) + winstype = 2; /* Do we have a homes share? */ have_home = lp_servicenumber(HOMES_NAME); @@ -709,106 +718,99 @@ static void wizard_page(void) role = lp_server_role(); /* Here we go ... */ - d_printf("<H2>Samba Configuration Wizard</H2>\n"); - d_printf("<form method=post action=wizard>\n"); + printf("<H2>Samba Configuration Wizard</H2>\n"); + printf("<form method=post action=wizard>\n"); if (have_write_access) { - d_printf(_("The \"Rewrite smb.conf file\" button will clear the smb.conf file of all default values and of comments.\n")); - d_printf(_("The same will happen if you press the commit button.")); - d_printf("<br><br>"); - d_printf("<center>"); - d_printf("<input type=submit name=\"Rewrite\" value=%s> ",_("Rewrite smb.conf file")); - d_printf("<input type=submit name=\"Commit\" value=%s> ",_("Commit")); - d_printf("<input type=submit name=\"GetWizardParams\" value=%s>", _("Edit Parameter Values")); - d_printf("</center>"); - } - - d_printf("<hr>"); - d_printf("<center><table border=0>"); - d_printf("<tr><td><b>%s</b></td>\n", "Server Type: "); - d_printf("<td><input type=radio name=\"ServerType\" value=0 %s> Stand Alone </td>", (role == ROLE_STANDALONE) ? "checked" : ""); - d_printf("<td><input type=radio name=\"ServerType\" value=1 %s> Domain Member </td>", (role == ROLE_DOMAIN_MEMBER) ? "checked" : ""); - d_printf("<td><input type=radio name=\"ServerType\" value=2 %s> Domain Controller </td>", (role == ROLE_DOMAIN_PDC) ? "checked" : ""); - d_printf("</tr>"); + printf("The \"Rewrite smb.conf file\" button will clear the smb.conf file of all default values and of comments.\n"); + printf("The same will happen if you press the commit button."); + printf("<br><br>"); + printf("<center>"); + printf("<input type=submit name=\"Rewrite\" value=\"Rewrite smb.conf file\"> "); + printf("<input type=submit name=\"Commit\" value=\"Commit\"> "); + printf("<input type=submit name=\"GetWizardParams\" value=\"Edit Parameter Values\">"); + printf("</center>"); + } + + printf("<hr>"); + printf("<center><table border=0>"); + printf("<tr><td><b>%s</b></td>\n", "Server Type: "); + printf("<td><input type=radio name=\"ServerType\" value=0 %s> Stand Alone </td>", (role == ROLE_STANDALONE) ? "checked" : ""); + printf("<td><input type=radio name=\"ServerType\" value=1 %s> Domain Member </td>", (role == ROLE_DOMAIN_MEMBER) ? "checked" : ""); + printf("<td><input type=radio name=\"ServerType\" value=2 %s> Domain Controller </td>", (role == ROLE_DOMAIN_PDC) ? "checked" : ""); + printf("</tr>"); if (role == ROLE_DOMAIN_BDC) { - d_printf("<tr><td></td><td colspan=3><font color=\"#ff0000\">Unusual Type in smb.conf - Please Select New Mode</font></td></tr>"); + printf("<tr><td></td><td colspan=3><font color=\"#ff0000\">Unusual Type in smb.conf - Please Select New Mode</font></td></tr>"); } - d_printf("<tr><td><b>%s</b></td>\n", "Configure WINS As: "); - d_printf("<td><input type=radio name=\"WINSType\" value=0 %s> Not Used </td>", (winstype == 0) ? "checked" : ""); - d_printf("<td><input type=radio name=\"WINSType\" value=1 %s> Server for client use </td>", (winstype == 1) ? "checked" : ""); - d_printf("<td><input type=radio name=\"WINSType\" value=2 %s> Client of another WINS server </td>", (winstype == 2) ? "checked" : ""); - d_printf("<tr><td></td><td></td><td></td><td>Remote WINS Server <input type=text size=\"16\" name=\"WINSAddr\" value=\"%s\"></td></tr>",lp_wins_server_list()); + printf("<tr><td><b>%s</b></td>\n", "Configure WINS As: "); + printf("<td><input type=radio name=\"WINSType\" value=0 %s> Not Used </td>", (winstype == 0) ? "checked" : ""); + printf("<td><input type=radio name=\"WINSType\" value=1 %s> Server for client use </td>", (winstype == 1) ? "checked" : ""); + printf("<td><input type=radio name=\"WINSType\" value=2 %s> Client of another WINS server </td>", (winstype == 2) ? "checked" : ""); + printf("<tr><td></td><td></td><td></td><td>Remote WINS Server <input type=text size=\"16\" name=\"WINSAddr\" value=\"\%s\"></td></tr>",lp_wins_server()); if (winstype == 3) { - d_printf("<tr><td></td><td colspan=3><font color=\"#ff0000\">Error: WINS Server Mode and WINS Support both set in smb.conf</font></td></tr>"); - d_printf("<tr><td></td><td colspan=3><font color=\"#ff0000\">Please Select desired WINS mode above.</font></td></tr>"); - } - d_printf("</tr>"); - d_printf("<tr><td><b>%s</b></td>\n","Expose Home Directories: "); - d_printf("<td><input type=radio name=\"HomeExpo\" value=1 %s> Yes</td>", (have_home == -1) ? "" : "checked "); - d_printf("<td><input type=radio name=\"HomeExpo\" value=0 %s> No</td>", (have_home == -1 ) ? "checked" : ""); - d_printf("<td></td></tr>"); + printf("<tr><td></td><td colspan=3><font color=\"#ff0000\">Error: WINS Server Mode and WINS Support both set in smb.conf</font></td></tr>"); + printf("<tr><td></td><td colspan=3><font color=\"#ff0000\">Please Select desired WINS mode above.</font></td></tr>"); + } + printf("</tr>"); + printf("<tr><td><b>%s</b></td>\n","Expose Home Directories: "); + printf("<td><input type=radio name=\"HomeExpo\" value=1 %s> Yes</td>", (have_home == -1) ? "" : "checked "); + printf("<td><input type=radio name=\"HomeExpo\" value=0 %s> No</td>", (have_home == -1 ) ? "checked" : ""); + printf("<td></td></tr>"); /* Enable this when we are ready .... - * d_printf("<tr><td><b>%s</b></td>\n","Is Print Server: "); - * d_printf("<td><input type=radio name=\"PtrSvr\" value=1 %s> Yes</td>"); - * d_printf("<td><input type=radio name=\"PtrSvr\" value=0 %s> No</td>"); - * d_printf("<td></td></tr>"); + * printf("<tr><td><b>%s</b></td>\n","Is Print Server: "); + * printf("<td><input type=radio name=\"PtrSvr\" value=1 %s> Yes</td>"); + * printf("<td><input type=radio name=\"PtrSvr\" value=0 %s> No</td>"); + * printf("<td></td></tr>"); */ - d_printf("</table></center>"); - d_printf("<hr>"); + printf("</table></center>"); + printf("<hr>"); - d_printf(_("The above configuration options will set multiple parameters and will generally assist with rapid Samba deployment.\n")); - d_printf("</form>\n"); + printf("The above configuration options will set multiple parameters and will generally assist with rapid Samba deployment.\n"); + printf("</form>\n"); } - /**************************************************************************** display a globals editing page ****************************************************************************/ static void globals_page(void) { unsigned int parm_filter = FLAG_BASIC; - int mode = 0; - d_printf("<H2>%s</H2>\n", _("Global Variables")); + printf("<H2>Global Variables</H2>\n"); + + if (cgi_variable("Advanced") && !cgi_variable("Basic")) + parm_filter = FLAG_ADVANCED; if (cgi_variable("Commit")) { commit_parameters(GLOBALS_SNUM); save_reload(0); } - if ( cgi_variable("ViewMode") ) - mode = atoi(cgi_variable("ViewMode")); - - d_printf("<form name=\"swatform\" method=post action=globals>\n"); + printf("<FORM name=\"swatform\" method=post>\n"); - ViewModeBoxes( mode ); - switch ( mode ) { - case 0: - parm_filter = FLAG_BASIC; - break; - case 1: - parm_filter = FLAG_ADVANCED; - break; - case 2: - parm_filter = FLAG_DEVELOPER; - break; - } - d_printf("<br>\n"); if (have_write_access) { - d_printf("<input type=submit name=\"Commit\" value=\"%s\">\n", - _("Commit Changes")); + printf("<input type=submit name=\"Commit\" value=\"Commit Changes\">\n"); } - d_printf("<input type=reset name=\"Reset Values\" value=\"%s\">\n", - _("Reset Values")); - - d_printf("<p>\n"); - d_printf("<table>\n"); + printf("<input type=reset name=\"Reset Values\" value=\"Reset Values\">\n"); + if (parm_filter != FLAG_ADVANCED) { + printf("<input type=submit name=\"Advanced\" value=\"Advanced View\">\n"); + } else { + printf("<input type=submit name=\"Basic\" value=\"Basic View\">\n"); + } + printf("<p>\n"); + + printf("<table>\n"); show_parameters(GLOBALS_SNUM, 1, parm_filter, 0); - d_printf("</table>\n"); - d_printf("</form>\n"); + printf("</table>\n"); + + if (parm_filter == FLAG_ADVANCED) { + printf("<input type=hidden name=\"Advanced\" value=1>\n"); + } + + printf("</FORM>\n"); } /**************************************************************************** @@ -819,15 +821,17 @@ static void shares_page(void) { char *share = cgi_variable("share"); char *s; - int snum = -1; + int snum=-1; int i; - int mode = 0; unsigned int parm_filter = FLAG_BASIC; if (share) snum = lp_servicenumber(share); - d_printf("<H2>%s</H2>\n", _("Share Parameters")); + printf("<H2>Share Parameters</H2>\n"); + + if (cgi_variable("Advanced") && !cgi_variable("Basic")) + parm_filter = FLAG_ADVANCED; if (cgi_variable("Commit") && snum >= 0) { commit_parameters(snum); @@ -842,74 +846,73 @@ static void shares_page(void) } if (cgi_variable("createshare") && (share=cgi_variable("newshare"))) { + /* add_a_service() which is called by lp_copy_service() + will do unix_to_dos() conversion, so we need dos_to_unix() before the lp_copy_service(). */ + pstring unix_share; + pstrcpy(unix_share, dos_to_unix_static(share)); load_config(False); - lp_copy_service(GLOBALS_SNUM, share); + lp_copy_service(GLOBALS_SNUM, unix_share); iNumNonAutoPrintServices = lp_numservices(); save_reload(0); snum = lp_servicenumber(share); } - d_printf("<FORM name=\"swatform\" method=post>\n"); + printf("<FORM name=\"swatform\" method=post>\n"); - d_printf("<table>\n"); - if ( cgi_variable("ViewMode") ) - mode = atoi(cgi_variable("ViewMode")); - ViewModeBoxes( mode ); - switch ( mode ) { - case 0: - parm_filter = FLAG_BASIC; - break; - case 1: - parm_filter = FLAG_ADVANCED; - break; - case 2: - parm_filter = FLAG_DEVELOPER; - break; - } - d_printf("<br><tr>\n"); - d_printf("<td><input type=submit name=selectshare value=\"%s\"></td>\n", _("Choose Share")); - d_printf("<td><select name=share>\n"); + printf("<table>\n"); + printf("<tr>\n"); + printf("<td><input type=submit name=selectshare value=\"Choose Share\"></td>\n"); + printf("<td><select name=share>\n"); if (snum < 0) - d_printf("<option value=\" \"> \n"); + printf("<option value=\" \"> \n"); for (i=0;i<lp_numservices();i++) { s = lp_servicename(i); if (s && (*s) && strcmp(s,"IPC$") && !lp_print_ok(i)) { - d_printf("<option %s value=\"%s\">%s\n", + printf("<option %s value=\"%s\">%s\n", (share && strcmp(share,s)==0)?"SELECTED":"", s, s); } } - d_printf("</select></td>\n"); + printf("</select></td>\n"); if (have_write_access) { - d_printf("<td><input type=submit name=\"Delete\" value=\"%s\"></td>\n", _("Delete Share")); + printf("<td><input type=submit name=\"Delete\" value=\"Delete Share\"></td>\n"); } - d_printf("</tr>\n"); - d_printf("</table>"); - d_printf("<table>"); + printf("</tr>\n"); + printf("</table>"); + printf("<table>"); if (have_write_access) { - d_printf("<tr>\n"); - d_printf("<td><input type=submit name=createshare value=\"%s\"></td>\n", _("Create Share")); - d_printf("<td><input type=text size=30 name=newshare></td></tr>\n"); + printf("<tr>\n"); + printf("<td><input type=submit name=createshare value=\"Create Share\"></td>\n"); + printf("<td><input type=text size=30 name=newshare></td></tr>\n"); } - d_printf("</table>"); + printf("</table>"); if (snum >= 0) { if (have_write_access) { - d_printf("<input type=submit name=\"Commit\" value=\"%s\">\n", _("Commit Changes")); + printf("<input type=submit name=\"Commit\" value=\"Commit Changes\">\n"); } - d_printf("<input type=reset name=\"Reset Values\" value=\"%s\">\n", _("Reset Values")); - d_printf("<p>\n"); + printf("<input type=reset name=\"Reset Values\" value=\"Reset Values\">\n"); + if (parm_filter != FLAG_ADVANCED) { + printf("<input type=submit name=\"Advanced\" value=\"Advanced View\">\n"); + } else { + printf("<input type=submit name=\"Basic\" value=\"Basic View\">\n"); + } + printf("<p>\n"); } if (snum >= 0) { - d_printf("<table>\n"); + printf("<table>\n"); show_parameters(snum, 1, parm_filter, 0); - d_printf("</table>\n"); + printf("</table>\n"); + } + + if (parm_filter == FLAG_ADVANCED) { + printf("<input type=hidden name=\"Advanced\" value=1>\n"); } - d_printf("</FORM>\n"); + printf("</FORM>\n"); } /************************************************************* @@ -924,7 +927,7 @@ static BOOL change_password(const char *remote_machine, char *user_name, pstring msg_str; if (demo_mode) { - d_printf("%s<p>", _("password change in demo mode rejected\n")); + printf("password change in demo mode rejected\n<p>"); return False; } @@ -932,12 +935,12 @@ static BOOL change_password(const char *remote_machine, char *user_name, ret = remote_password_change(remote_machine, user_name, old_passwd, new_passwd, err_str, sizeof(err_str)); if(*err_str) - d_printf("%s\n<p>", err_str); + printf("%s\n<p>", err_str); return ret; } - if(!initialize_password_db(True)) { - d_printf("Can't setup password database vectors.\n<p>"); + if(!initialize_password_db(False)) { + printf("Can't setup password database vectors.\n<p>"); return False; } @@ -945,9 +948,9 @@ static BOOL change_password(const char *remote_machine, char *user_name, msg_str, sizeof(msg_str)); if(*msg_str) - d_printf("%s\n<p>", msg_str); + printf("%s\n<p>", msg_str); if(*err_str) - d_printf("%s\n<p>", err_str); + printf("%s\n<p>", err_str); return ret; } @@ -963,7 +966,7 @@ static void chg_passwd(void) /* Make sure users name has been specified */ if (strlen(cgi_variable(SWAT_USER)) == 0) { - d_printf("<p>%s", _(" Must specify \"User Name\" \n")); + printf("<p> Must specify \"User Name\" \n"); return; } @@ -979,26 +982,26 @@ static void chg_passwd(void) */ if (((!am_root()) && (strlen( cgi_variable(OLD_PSWD)) <= 0)) || ((cgi_variable(CHG_R_PASSWD_FLAG)) && (strlen( cgi_variable(OLD_PSWD)) <= 0))) { - d_printf("<p>%s", _(" Must specify \"Old Password\" \n")); + printf("<p> Must specify \"Old Password\" \n"); return; } /* If changing a users password on a remote hosts we have to know what host */ if ((cgi_variable(CHG_R_PASSWD_FLAG)) && (strlen( cgi_variable(RHOST)) <= 0)) { - d_printf("<p>%s", _(" Must specify \"Remote Machine\" \n")); + printf("<p> Must specify \"Remote Machine\" \n"); return; } /* Make sure new passwords have been specified */ if ((strlen( cgi_variable(NEW_PSWD)) <= 0) || (strlen( cgi_variable(NEW2_PSWD)) <= 0)) { - d_printf("<p>%s", _(" Must specify \"New, and Re-typed Passwords\" \n")); + printf("<p> Must specify \"New, and Re-typed Passwords\" \n"); return; } /* Make sure new passwords was typed correctly twice */ if (strcmp(cgi_variable(NEW_PSWD), cgi_variable(NEW2_PSWD)) != 0) { - d_printf("<p>%s", _(" Re-typed password didn't match new password\n")); + printf("<p> Re-typed password didn't match new password\n"); return; } } @@ -1026,11 +1029,10 @@ static void chg_passwd(void) local_flags); if(local_flags == 0) { - d_printf("<p>"); if (rslt == True) { - d_printf(_(" The passwd for '%s' has been changed. \n"), cgi_variable(SWAT_USER)); + printf("<p> The passwd for '%s' has been changed. \n", cgi_variable(SWAT_USER)); } else { - d_printf(_(" The passwd for '%s' has NOT been changed. \n"), cgi_variable(SWAT_USER)); + printf("<p> The passwd for '%s' has NOT been changed. \n",cgi_variable(SWAT_USER)); } } @@ -1054,43 +1056,43 @@ static void passwd_page(void) if (!new_name) new_name = ""; - d_printf("<H2>%s</H2>\n", _("Server Password Management")); + printf("<H2>Server Password Management</H2>\n"); - d_printf("<FORM name=\"swatform\" method=post>\n"); + printf("<FORM name=\"swatform\" method=post>\n"); - d_printf("<table>\n"); + printf("<table>\n"); /* * Create all the dialog boxes for data collection */ - d_printf("<tr><td>%s</td>\n", _(" User Name : ")); - d_printf("<td><input type=text size=30 name=%s value=%s></td></tr> \n", SWAT_USER, new_name); + printf("<tr><td> User Name : </td>\n"); + printf("<td><input type=text size=30 name=%s value=%s></td></tr> \n", SWAT_USER, new_name); if (!am_root()) { - d_printf("<tr><td>%s</td>\n", _(" Old Password : ")); - d_printf("<td><input type=password size=30 name=%s></td></tr> \n",OLD_PSWD); + printf("<tr><td> Old Password : </td>\n"); + printf("<td><input type=password size=30 name=%s></td></tr> \n",OLD_PSWD); } - d_printf("<tr><td>%s</td>\n", _(" New Password : ")); - d_printf("<td><input type=password size=30 name=%s></td></tr>\n",NEW_PSWD); - d_printf("<tr><td>%s</td>\n", _(" Re-type New Password : ")); - d_printf("<td><input type=password size=30 name=%s></td></tr>\n",NEW2_PSWD); - d_printf("</table>\n"); + printf("<tr><td> New Password : </td>\n"); + printf("<td><input type=password size=30 name=%s></td></tr>\n",NEW_PSWD); + printf("<tr><td> Re-type New Password : </td>\n"); + printf("<td><input type=password size=30 name=%s></td></tr>\n",NEW2_PSWD); + printf("</table>\n"); /* * Create all the control buttons for requesting action */ - d_printf("<input type=submit name=%s value=\"%s\">\n", - CHG_S_PASSWD_FLAG, _("Change Password")); + printf("<input type=submit name=%s value=\"Change Password\">\n", + CHG_S_PASSWD_FLAG); if (demo_mode || am_root()) { - d_printf("<input type=submit name=%s value=\"%s\">\n", - ADD_USER_FLAG, _("Add New User")); - d_printf("<input type=submit name=%s value=\"%s\">\n", - DELETE_USER_FLAG, _("Delete User")); - d_printf("<input type=submit name=%s value=\"%s\">\n", - DISABLE_USER_FLAG, _("Disable User")); - d_printf("<input type=submit name=%s value=\"%s\">\n", - ENABLE_USER_FLAG, _("Enable User")); + printf("<input type=submit name=%s value=\"Add New User\">\n", + ADD_USER_FLAG); + printf("<input type=submit name=%s value=\"Delete User\">\n", + DELETE_USER_FLAG); + printf("<input type=submit name=%s value=\"Disable User\">\n", + DISABLE_USER_FLAG); + printf("<input type=submit name=%s value=\"Enable User\">\n", + ENABLE_USER_FLAG); } - d_printf("<p></FORM>\n"); + printf("<p></FORM>\n"); /* * Do some work if change, add, disable or enable was @@ -1101,35 +1103,35 @@ static void passwd_page(void) chg_passwd(); } - d_printf("<H2>%s</H2>\n", _("Client/Server Password Management")); + printf("<H2>Client/Server Password Management</H2>\n"); - d_printf("<FORM name=\"swatform\" method=post>\n"); + printf("<FORM name=\"swatform\" method=post>\n"); - d_printf("<table>\n"); + printf("<table>\n"); /* * Create all the dialog boxes for data collection */ - d_printf("<tr><td>%s</td>\n", _(" User Name : ")); - d_printf("<td><input type=text size=30 name=%s value=%s></td></tr>\n",SWAT_USER, new_name); - d_printf("<tr><td>%s</td>\n", _(" Old Password : ")); - d_printf("<td><input type=password size=30 name=%s></td></tr>\n",OLD_PSWD); - d_printf("<tr><td>%s</td>\n", _(" New Password : ")); - d_printf("<td><input type=password size=30 name=%s></td></tr>\n",NEW_PSWD); - d_printf("<tr><td>%s</td>\n", _(" Re-type New Password : ")); - d_printf("<td><input type=password size=30 name=%s></td></tr>\n",NEW2_PSWD); - d_printf("<tr><td>%s</td>\n", _(" Remote Machine : ")); - d_printf("<td><input type=text size=30 name=%s></td></tr>\n",RHOST); - - d_printf("</table>"); + printf("<tr><td> User Name : </td>\n"); + printf("<td><input type=text size=30 name=%s value=%s></td></tr>\n",SWAT_USER, new_name); + printf("<tr><td> Old Password : </td>\n"); + printf("<td><input type=password size=30 name=%s></td></tr>\n",OLD_PSWD); + printf("<tr><td> New Password : </td>\n"); + printf("<td><input type=password size=30 name=%s></td></tr>\n",NEW_PSWD); + printf("<tr><td> Re-type New Password : </td>\n"); + printf("<td><input type=password size=30 name=%s></td></tr>\n",NEW2_PSWD); + printf("<tr><td> Remote Machine : </td>\n"); + printf("<td><input type=text size=30 name=%s></td></tr>\n",RHOST); + + printf("</table>"); /* * Create all the control buttons for requesting action */ - d_printf("<input type=submit name=%s value=\"%s\">", - CHG_R_PASSWD_FLAG, _("Change Password")); + printf("<input type=submit name=%s value=\"Change Password\">", + CHG_R_PASSWD_FLAG); - d_printf("<p></FORM>\n"); + printf("<p></FORM>\n"); /* * Do some work if a request has been made to change the @@ -1151,19 +1153,21 @@ static void printers_page(void) char *s; int snum=-1; int i; - int mode = 0; unsigned int parm_filter = FLAG_BASIC; if (share) snum = lp_servicenumber(share); - d_printf("<H2>%s</H2>\n", _("Printer Parameters")); - - d_printf("<H3>%s</H3>\n", _("Important Note:")); - d_printf(_("Printer names marked with [*] in the Choose Printer drop-down box ")); - d_printf(_("are autoloaded printers from ")); - d_printf("<A HREF=\"/swat/help/smb.conf.5.html#printcapname\" target=\"docs\">%s</A>\n", _("Printcap Name")); - d_printf(_("Attempting to delete these printers from SWAT will have no effect.\n")); + printf("<H2>Printer Parameters</H2>\n"); + + printf("<H3>Important Note:</H3>\n"); + printf("Printer names marked with [*] in the Choose Printer drop-down box "); + printf("are autoloaded printers from "); + printf("<A HREF=\"/swat/help/smb.conf.5.html#PRINTCAPNAME\" target=\"docs\">Printcap Name</A>.\n"); + printf("Attempting to delete these printers from SWAT will have no effect.\n"); + + if (cgi_variable("Advanced") && !cgi_variable("Basic")) + parm_filter = FLAG_ADVANCED; if (cgi_variable("Commit") && snum >= 0) { commit_parameters(snum); @@ -1181,8 +1185,12 @@ static void printers_page(void) } if (cgi_variable("createshare") && (share=cgi_variable("newshare"))) { + /* add_a_service() which is called by lp_copy_service() + will do unix_to_dos() conversion, so we need dos_to_unix() before the lp_copy_service(). */ + pstring unix_share; + pstrcpy(unix_share, dos_to_unix_static(share)); load_config(False); - lp_copy_service(GLOBALS_SNUM, share); + lp_copy_service(GLOBALS_SNUM, unix_share); iNumNonAutoPrintServices = lp_numservices(); snum = lp_servicenumber(share); lp_do_parameter(snum, "print ok", "Yes"); @@ -1190,79 +1198,75 @@ static void printers_page(void) snum = lp_servicenumber(share); } - d_printf("<FORM name=\"swatform\" method=post>\n"); + printf("<FORM name=\"swatform\" method=post>\n"); - if ( cgi_variable("ViewMode") ) - mode = atoi(cgi_variable("ViewMode")); - ViewModeBoxes( mode ); - switch ( mode ) { - case 0: - parm_filter = FLAG_BASIC; - break; - case 1: - parm_filter = FLAG_ADVANCED; - break; - case 2: - parm_filter = FLAG_DEVELOPER; - break; - } - d_printf("<table>\n"); - d_printf("<tr><td><input type=submit name=selectshare value=\"%s\"></td>\n", _("Choose Printer")); - d_printf("<td><select name=share>\n"); + printf("<table>\n"); + printf("<tr><td><input type=submit name=selectshare value=\"Choose Printer\"></td>\n"); + printf("<td><select name=share>\n"); if (snum < 0 || !lp_print_ok(snum)) - d_printf("<option value=\" \"> \n"); + printf("<option value=\" \"> \n"); for (i=0;i<lp_numservices();i++) { s = lp_servicename(i); if (s && (*s) && strcmp(s,"IPC$") && lp_print_ok(i)) { if (i >= iNumNonAutoPrintServices) - d_printf("<option %s value=\"%s\">[*]%s\n", + printf("<option %s value=\"%s\">[*]%s\n", (share && strcmp(share,s)==0)?"SELECTED":"", s, s); else - d_printf("<option %s value=\"%s\">%s\n", + printf("<option %s value=\"%s\">%s\n", (share && strcmp(share,s)==0)?"SELECTED":"", s, s); } } - d_printf("</select></td>"); + printf("</select></td>"); if (have_write_access) { - d_printf("<td><input type=submit name=\"Delete\" value=\"%s\"></td>\n", _("Delete Printer")); + printf("<td><input type=submit name=\"Delete\" value=\"Delete Printer\"></td>\n"); } - d_printf("</tr>"); - d_printf("</table>\n"); + printf("</tr>"); + printf("</table>\n"); if (have_write_access) { - d_printf("<table>\n"); - d_printf("<tr><td><input type=submit name=createshare value=\"%s\"></td>\n", _("Create Printer")); - d_printf("<td><input type=text size=30 name=newshare></td></tr>\n"); - d_printf("</table>"); + printf("<table>\n"); + printf("<tr><td><input type=submit name=createshare value=\"Create Printer\"></td>\n"); + printf("<td><input type=text size=30 name=newshare></td></tr>\n"); + printf("</table>"); } if (snum >= 0) { if (have_write_access) { - d_printf("<input type=submit name=\"Commit\" value=\"%s\">\n", _("Commit Changes")); + printf("<input type=submit name=\"Commit\" value=\"Commit Changes\">\n"); } - d_printf("<input type=reset name=\"Reset Values\" value=\"%s\">\n", _("Reset Values")); - d_printf("<p>\n"); + printf("<input type=reset name=\"Reset Values\" value=\"Reset Values\">\n"); + if (parm_filter != FLAG_ADVANCED) { + printf("<input type=submit name=\"Advanced\" value=\"Advanced View\">\n"); + } else { + printf("<input type=submit name=\"Basic\" value=\"Basic View\">\n"); + } + printf("<p>\n"); } if (snum >= 0) { - d_printf("<table>\n"); + printf("<table>\n"); show_parameters(snum, 1, parm_filter, 1); - d_printf("</table>\n"); + printf("</table>\n"); } - d_printf("</FORM>\n"); -} + if (parm_filter == FLAG_ADVANCED) { + printf("<input type=hidden name=\"Advanced\" value=1>\n"); + } + + printf("</FORM>\n"); +} -/** - * main function for SWAT. - **/ +/**************************************************************************** + MAIN() +****************************************************************************/ int main(int argc, char *argv[]) { extern char *optarg; extern int optind; + extern FILE *dbf; int opt; char *page; @@ -1276,13 +1280,11 @@ static void printers_page(void) /* just in case it goes wild ... */ alarm(300); - setlinebuf(stdout); - /* we don't want any SIGPIPE messages */ BlockSignals(True,SIGPIPE); - dbf = x_fopen("/dev/null", O_WRONLY, 0); - if (!dbf) dbf = x_stderr; + dbf = sys_fopen("/dev/null", "w"); + if (!dbf) dbf = stderr; /* we don't want stderr screwing us up */ close(2); @@ -1291,38 +1293,41 @@ static void printers_page(void) while ((opt = getopt(argc, argv,"s:a")) != EOF) { switch (opt) { case 's': - pstrcpy(dyn_CONFIGFILE,optarg); + pstrcpy(servicesf,optarg); break; case 'a': demo_mode = True; - break; + break; } } - + setup_logging(argv[0],False); + charset_initialise(); load_config(True); iNumNonAutoPrintServices = lp_numservices(); load_printers(); + codepage_initialise(lp_client_code_page()); - cgi_setup(dyn_SWATDIR, !demo_mode); + cgi_setup(SWATDIR, !demo_mode); print_header(); + + cgi_load_variables(NULL); - cgi_load_variables(); - - if (!file_exist(dyn_CONFIGFILE, NULL)) { + if (!file_exist(servicesf, NULL)) { have_read_access = True; have_write_access = True; } else { /* check if the authenticated user has write access - if not then don't show write options */ - have_write_access = (access(dyn_CONFIGFILE,W_OK) == 0); + have_write_access = (access(servicesf,W_OK) == 0); /* if the user doesn't have read access to smb.conf then don't let them view it */ - have_read_access = (access(dyn_CONFIGFILE,R_OK) == 0); + have_read_access = (access(servicesf,R_OK) == 0); } + show_main_buttons(); page = cgi_pathinfo(); @@ -1334,18 +1339,18 @@ static void printers_page(void) shares_page(); } else if (have_read_access && strcmp(page,"printers")==0) { printers_page(); - } else if (have_read_access && strcmp(page,"status")==0) { - status_page(); - } else if (have_read_access && strcmp(page,"viewconfig")==0) { - viewconfig_page(); - } else if (strcmp(page,"passwd")==0) { - passwd_page(); } else if (have_read_access && strcmp(page,"wizard")==0) { wizard_page(); } else if (have_read_access && strcmp(page,"wizard_params")==0) { wizard_params_page(); + } else if (have_read_access && strcmp(page,"status")==0) { + status_page(); + } else if (have_read_access && strcmp(page,"viewconfig")==0) { + viewconfig_page(); } else if (have_read_access && strcmp(page,"rewritecfg")==0) { rewritecfg_file(); + } else if (strcmp(page,"passwd")==0) { + passwd_page(); } else { welcome_page(); } @@ -1353,5 +1358,3 @@ static void printers_page(void) print_footer(); return 0; } - -/** @} **/ |