From 3db52feb1f3b2c07ce0b06ad4a7099fa6efe3fc7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:27:58 +0000 Subject: first pass at updating head branch to be to be the same as the SAMBA_2_0 branch (This used to be commit 453a822a76780063dff23526c35408866d0c0154) --- source3/web/swat.c | 209 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 137 insertions(+), 72 deletions(-) (limited to 'source3/web/swat.c') diff --git a/source3/web/swat.c b/source3/web/swat.c index ce7801ba5c..48c3ae07e2 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -31,6 +31,8 @@ static pstring servicesf = CONFIGFILE; static BOOL demo_mode = False; static BOOL have_write_access = False; +static BOOL have_read_access = False; +static int iNumNonAutoPrintServices = 0; /* * Password Management Globals @@ -215,9 +217,10 @@ static void show_parameter(int snum, struct parm_struct *parm) break; case P_OCTAL: - printf("", make_parm_name(parm->label), *(int *)ptr); - printf("", - make_parm_name(parm->label),(int)(parm->def.ivalue)); + printf("", make_parm_name(parm->label), octal_string(*(int *)ptr)); + printf("", + make_parm_name(parm->label), + octal_string((int)(parm->def.ivalue))); break; case P_ENUM: @@ -252,10 +255,18 @@ static void show_parameters(int snum, int allparameters, int advanced, int print continue; } if (parm->flags & FLAG_HIDE) continue; + if (snum >= 0) { + if (printers & !(parm->flags & FLAG_PRINT)) continue; + if (!printers & !(parm->flags & FLAG_SHARE)) continue; + } if (!advanced) { - if (!printers && !(parm->flags & FLAG_BASIC)) { + if (!(parm->flags & FLAG_BASIC)) { void *ptr = parm->ptr; + if (parm->class == P_LOCAL && snum >= 0) { + ptr = lp_local_ptr(snum, ptr); + } + switch (parm->type) { case P_CHAR: if (*(char *)ptr == (char)(parm->def.cvalue)) continue; @@ -299,6 +310,15 @@ static void show_parameters(int snum, int allparameters, int advanced, int print } } +/**************************************************************************** + load the smb.conf file into loadparm. +****************************************************************************/ +static BOOL load_config(BOOL save_def) +{ + lp_resetnumservices(); + return lp_load(servicesf,False,save_def,False); +} + /**************************************************************************** write a config file ****************************************************************************/ @@ -306,15 +326,15 @@ static void write_config(FILE *f, BOOL show_defaults) { 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()); + fprintf(f, "# Date: %s\n\n", timestring(False)); - lp_dump(f, show_defaults); + lp_dump(f, show_defaults, iNumNonAutoPrintServices); } /**************************************************************************** save and reoad the smb.conf config file ****************************************************************************/ -static int save_reload(void) +static int save_reload(int snum) { FILE *f; @@ -325,14 +345,18 @@ static int save_reload(void) } write_config(f, False); + if (snum) + lp_dump_one(f, False, snum); fclose(f); lp_killunused(NULL); - if (!lp_load(servicesf,False,False,False)) { + if (!load_config(False)) { printf("Can't reload %s\n", servicesf); return 0; } + iNumNonAutoPrintServices = lp_numservices(); + load_printers(); return 1; } @@ -379,14 +403,6 @@ static void commit_parameters(int snum) } } -/**************************************************************************** - load the smb.conf file into loadparm. -****************************************************************************/ -static BOOL load_config(void) -{ - return lp_load(servicesf,False,True,False); -} - /**************************************************************************** spit out the html for a link with an image ****************************************************************************/ @@ -402,13 +418,22 @@ static void image_link(char *name,char *hlink, char *src) ****************************************************************************/ static void show_main_buttons(void) { - image_link("Home", "", "images/home.gif"); + char *p; + + if ((p = cgi_user_name()) && strcmp(p, "root")) { + printf("Logged in as %s

\n", p); + } - image_link("Globals", "globals", "images/globals.gif"); - image_link("Shares", "shares", "images/shares.gif"); - image_link("Printers", "printers", "images/printers.gif"); - image_link("Status", "status", "images/status.gif"); - image_link("View Config", "viewconfig","images/viewconfig.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"); + } + if (have_read_access) { + image_link("Status", "status", "images/status.gif"); + image_link("View Config", "viewconfig","images/viewconfig.gif"); + } image_link("Password Management", "passwd", "images/passwd.gif"); printf("


\n"); @@ -462,7 +487,7 @@ static void globals_page(void) if (cgi_variable("Commit")) { commit_parameters(GLOBALS_SNUM); - save_reload(); + save_reload(0); } printf("
\n"); @@ -511,26 +536,29 @@ static void shares_page(void) if (cgi_variable("Commit") && snum >= 0) { commit_parameters(snum); - save_reload(); + save_reload(0); } if (cgi_variable("Delete") && snum >= 0) { lp_remove_service(snum); - save_reload(); + save_reload(0); share = NULL; snum = -1; } if (cgi_variable("createshare") && (share=cgi_variable("newshare"))) { + load_config(False); lp_copy_service(GLOBALS_SNUM, share); - save_reload(); + iNumNonAutoPrintServices = lp_numservices(); + save_reload(0); snum = lp_servicenumber(share); } printf("\n"); printf("\n"); - printf("\n"); + printf("\n"); + printf("\n"); printf("

"); - - printf("

\n"); - printf("\n"); + printf("\n"); + if (have_write_access) { + printf("\n"); + } + printf("\n"); + printf("
"); + printf(""); + if (have_write_access) { + printf("\n"); + printf("\n"); + printf("\n"); + } printf("
"); @@ -554,7 +590,7 @@ static void shares_page(void) printf("\n"); } - printf("\n"); + printf("\n"); if (advanced == 0) { printf("\n"); } else { @@ -584,8 +620,6 @@ static BOOL change_password(const char *remote_machine, char *user_name, BOOL add_user, BOOL enable_user, BOOL disable_user) { BOOL ret = False; - uint16 acb_info = 0; - uint16 acb_mask = 0; pstring err_str; pstring msg_str; @@ -602,28 +636,14 @@ static BOOL change_password(const char *remote_machine, char *user_name, return ret; } - if (!pwdb_initialise(False)) - { + if(!initialize_password_db()) { printf("Can't setup password database vectors.\n

"); return False; } - if (enable_user) - { - acb_mask |= ACB_DISABLED; - acb_info &= ~ACB_DISABLED; - } - - if (disable_user) - { - acb_mask |= ACB_DISABLED; - acb_info |= ACB_DISABLED; - } - - ret = local_password_change(user_name, add_user, - acb_info, acb_mask, - new_passwd, err_str, sizeof(err_str), - msg_str, sizeof(msg_str)); + ret = local_password_change(user_name, False, add_user, enable_user, + disable_user, False, new_passwd, err_str, sizeof(err_str), + msg_str, sizeof(msg_str)); if(*msg_str) printf("%s\n

", msg_str); @@ -787,7 +807,7 @@ static void passwd_page(void) printf(" Re-type New Password : \n"); printf("\n",NEW2_PSWD); printf(" Remote Machine : \n"); - printf("\n",RHOST); + printf("\n",RHOST); printf(""); @@ -826,26 +846,37 @@ static void printers_page(void) printf("

Printer Parameters

\n"); + printf("

Important Note:

\n"); + printf("Printer names marked with [*] in the Choose Printer drop-down box "); + printf("are autoloaded printers from "); + printf("Printcap Name.\n"); + printf("Attempting to delete these printers from SWAT will have no effect.\n"); + if (cgi_variable("Advanced") && !cgi_variable("Basic")) advanced = 1; if (cgi_variable("Commit") && snum >= 0) { commit_parameters(snum); - save_reload(); + if (snum >= iNumNonAutoPrintServices) + save_reload(snum); + else + save_reload(0); } if (cgi_variable("Delete") && snum >= 0) { lp_remove_service(snum); - save_reload(); + save_reload(0); share = NULL; snum = -1; } if (cgi_variable("createshare") && (share=cgi_variable("newshare"))) { + load_config(False); lp_copy_service(GLOBALS_SNUM, share); + iNumNonAutoPrintServices = lp_numservices(); snum = lp_servicenumber(share); lp_do_parameter(snum, "print ok", "Yes"); - save_reload(); + save_reload(0); snum = lp_servicenumber(share); } @@ -859,23 +890,36 @@ static void printers_page(void) for (i=0;i= iNumNonAutoPrintServices) + printf("