diff options
author | Gerald Carter <jerry@samba.org> | 2005-09-30 17:13:37 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:04:48 -0500 |
commit | 54abd2aa66069e6baf7769c496f46d9dba18db39 (patch) | |
tree | 9cf8e88168011797319ba9e9866749201b1eac1e /source3/web | |
parent | 4a2cc231d22a82ed21771a72508f15d21ed63227 (diff) | |
download | samba-54abd2aa66069e6baf7769c496f46d9dba18db39.tar.gz samba-54abd2aa66069e6baf7769c496f46d9dba18db39.tar.bz2 samba-54abd2aa66069e6baf7769c496f46d9dba18db39.zip |
r10656: BIG merge from trunk. Features not copied over
* \PIPE\unixinfo
* winbindd's {group,alias}membership new functions
* winbindd's lookupsids() functionality
* swat (trunk changes to be reverted as per discussion with Deryck)
(This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3)
Diffstat (limited to 'source3/web')
-rw-r--r-- | source3/web/diagnose.c | 4 | ||||
-rw-r--r-- | source3/web/neg_lang.c | 4 | ||||
-rw-r--r-- | source3/web/startstop.c | 6 | ||||
-rw-r--r-- | source3/web/statuspage.c | 34 | ||||
-rw-r--r-- | source3/web/swat.c | 142 |
5 files changed, 125 insertions, 65 deletions
diff --git a/source3/web/diagnose.c b/source3/web/diagnose.c index d259717da0..c7a7a3598e 100644 --- a/source3/web/diagnose.c +++ b/source3/web/diagnose.c @@ -21,8 +21,6 @@ #include "includes.h" #include "web/swat_proto.h" -extern struct in_addr loopback_ip; - #ifdef WITH_WINBIND /* check to see if winbind is running by pinging it */ @@ -37,6 +35,7 @@ BOOL winbindd_running(void) response */ BOOL nmbd_running(void) { + extern struct in_addr loopback_ip; int fd, count, flags; struct in_addr *ip_list; @@ -61,6 +60,7 @@ BOOL nmbd_running(void) BOOL smbd_running(void) { static struct cli_state cli; + extern struct in_addr loopback_ip; if (!cli_initialise(&cli)) return False; diff --git a/source3/web/neg_lang.c b/source3/web/neg_lang.c index cc2924afde..ca671822d8 100644 --- a/source3/web/neg_lang.c +++ b/source3/web/neg_lang.c @@ -54,8 +54,8 @@ struct pri_list { }; static int qsort_cmp_list(const void *x, const void *y) { - struct pri_list *a = CONST_DISCARD(struct pri_list *, x); - struct pri_list *b = CONST_DISCARD(struct pri_list *, y); + struct pri_list *a = (struct pri_list *)x; + struct pri_list *b = (struct pri_list *)y; if (a->pri > b->pri) return -1; if (a->pri == b->pri) return 0; return 1; diff --git a/source3/web/startstop.c b/source3/web/startstop.c index 9ffda5bb94..8f28748918 100644 --- a/source3/web/startstop.c +++ b/source3/web/startstop.c @@ -121,11 +121,11 @@ void stop_winbindd(void) } #endif /* kill a specified process */ -void kill_pid(pid_t pid) +void kill_pid(struct process_id pid) { if (geteuid() != 0) return; - if (pid <= 0) return; + if (procid_to_pid(&pid) <= 0) return; - kill(pid, SIGTERM); + kill(procid_to_pid(&pid), SIGTERM); } diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 871e07b5d0..edc0318373 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -28,14 +28,14 @@ PIDMAP { PIDMAP *next, *prev; - pid_t pid; + struct process_id pid; char *machine; }; static PIDMAP *pidmap; static int PID_or_Machine; /* 0 = show PID, else show Machine name */ -static pid_t smbd_pid; +static struct process_id smbd_pid; /* from 2nd call on, remove old list */ static void initPid2Machine (void) @@ -55,7 +55,7 @@ static void initPid2Machine (void) } /* add new PID <-> Machine name mapping */ -static void addPid2Machine (pid_t pid, char *machine) +static void addPid2Machine (struct process_id pid, char *machine) { /* show machine name rather PID on table "Open Files"? */ if (PID_or_Machine) { @@ -75,7 +75,7 @@ static void addPid2Machine (pid_t pid, char *machine) } /* lookup PID <-> Machine name mapping */ -static char *mapPid2Machine (pid_t pid) +static char *mapPid2Machine (struct process_id pid) { static char pidbuf [64]; PIDMAP *map; @@ -83,7 +83,7 @@ static char *mapPid2Machine (pid_t pid) /* show machine name rather PID on table "Open Files"? */ if (PID_or_Machine) { for (map = pidmap; map != NULL; map = map->next) { - if (pid == map->pid) { + if (procid_equal(&pid, &map->pid)) { if (map->machine == NULL) /* no machine name */ break; /* show PID */ @@ -93,7 +93,8 @@ static char *mapPid2Machine (pid_t pid) } /* PID not in list or machine name NULL? return pid as string */ - snprintf (pidbuf, sizeof (pidbuf) - 1, "%lu", (unsigned long)pid); + snprintf (pidbuf, sizeof (pidbuf) - 1, "%s", + procid_str_static(&pid)); return pidbuf; } @@ -105,7 +106,7 @@ static char *tstring(time_t t) return buf; } -static void print_share_mode(share_mode_entry *e, char *fname) +static void print_share_mode(const struct share_mode_entry *e, char *fname) { char *utf8_fname; int deny_mode = map_share_mode_to_deny_mode(e->share_access, @@ -167,7 +168,7 @@ static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st if (crec.cnum == -1 && process_exists(crec.pid)) { char buf[30]; - slprintf(buf,sizeof(buf)-1,"kill_%d", (int)crec.pid); + slprintf(buf,sizeof(buf)-1,"kill_%s", procid_str_static(&crec.pid)); if (cgi_variable(buf)) { kill_pid(crec.pid); sleep(SLEEP_TIME); @@ -186,18 +187,19 @@ static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st memcpy(&crec, dbuf.dptr, sizeof(crec)); - if (crec.cnum == -1 || !process_exists(crec.pid) || (crec.pid == smbd_pid)) + if (crec.cnum == -1 || !process_exists(crec.pid) || + procid_equal(&crec.pid, &smbd_pid)) return 0; addPid2Machine (crec.pid, crec.machine); - printf("<tr><td>%d</td><td>%s</td><td>%s</td><td>%s</td>\n", - (int)crec.pid, + printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td>\n", + procid_str_static(&crec.pid), crec.machine,crec.addr, tstring(crec.start)); if (geteuid() == 0) { - printf("<td><input type=submit value=\"X\" name=\"kill_%d\"></td>\n", - (int)crec.pid); + printf("<td><input type=submit value=\"X\" name=\"kill_%s\"></td>\n", + procid_str_static(&crec.pid)); } printf("</tr>\n"); @@ -217,9 +219,9 @@ static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st if (crec.cnum == -1 || !process_exists(crec.pid)) return 0; - printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%s</td><td>%s</td></tr>\n", + printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", crec.name,uidtoname(crec.uid), - gidtoname(crec.gid),(int)crec.pid, + gidtoname(crec.gid),procid_str_static(&crec.pid), crec.machine, tstring(crec.start)); return 0; @@ -236,7 +238,7 @@ void status_page(void) int nr_running=0; BOOL waitup = False; - smbd_pid = pidfile_pid("smbd"); + smbd_pid = pid_to_procid(pidfile_pid("smbd")); if (cgi_variable("smbd_restart") || cgi_variable("all_restart")) { stop_smbd(); diff --git a/source3/web/swat.c b/source3/web/swat.c index 15612484a3..4082574e44 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -188,12 +188,12 @@ static const char* get_parm_translated( if(strcmp(pLabel, pTranslated) != 0) { pstr_sprintf(output, - "<A HREF=\"/swat/help/manpages/smb.conf.5.html#%s\" target=\"docs\"> %s</A> %s <br><span class=\"i18n_translated_parm\">%s</span>", + "<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; } pstr_sprintf(output, - "<A HREF=\"/swat/help/manpages/smb.conf.5.html#%s\" target=\"docs\"> %s</A> %s", + "<a href=\"/swat/help/smb.conf.5.html#%s\" target=\"docs\" class=\"help_link\"> %s</a> %s", pAnchor, pHelp, pLabel); return output; } @@ -220,7 +220,7 @@ static void show_parameter(int snum, struct parm_struct *parm) ptr = lp_local_ptr(snum, ptr); } - printf("<tr><td>%s</td><td>", get_parm_translated(stripspaceupper(parm->label), _("Help"), parm->label)); + printf("<tr><td width=\"230\">%s</td><td>", get_parm_translated(stripspaceupper(parm->label), _("Help"), parm->label)); switch (parm->type) { case P_CHAR: printf("<input type=text size=2 name=\"parm_%s\" value=\"%c\">", @@ -230,7 +230,7 @@ static void show_parameter(int snum, struct parm_struct *parm) break; case P_LIST: - printf("<input type=text size=40 name=\"parm_%s\" value=\"", + printf("<input type=text size=30 name=\"parm_%s\" value=\"", make_parm_name(parm->label)); if ((char ***)ptr && *(char ***)ptr && **(char ***)ptr) { char **list = *(char ***)ptr; @@ -268,7 +268,7 @@ static void show_parameter(int snum, struct parm_struct *parm) case P_STRING: case P_USTRING: push_utf8_allocate(&utf8_s1, *(char **)ptr); - printf("<input type=text size=40 name=\"parm_%s\" value=\"%s\">", + printf("<input type=text size=30 name=\"parm_%s\" value=\"%s\">", make_parm_name(parm->label), fix_quotes(utf8_s1)); SAFE_FREE(utf8_s1); printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%s\'\">", @@ -278,7 +278,7 @@ static void show_parameter(int snum, struct parm_struct *parm) case P_GSTRING: case P_UGSTRING: push_utf8_allocate(&utf8_s1, (char *)ptr); - printf("<input type=text size=40 name=\"parm_%s\" value=\"%s\">", + printf("<input type=text size=30 name=\"parm_%s\" value=\"%s\">", make_parm_name(parm->label), fix_quotes(utf8_s1)); SAFE_FREE(utf8_s1); printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%s\'\">", @@ -523,42 +523,50 @@ static void commit_parameters(int snum) } /**************************************************************************** - spit out the html for a link with an image + generate html for rollovers ****************************************************************************/ -static void image_link(const char *name, const char *hlink, const char *src) +static void rollover_link(const char *name, const char *id, const char *page) { - printf("<A HREF=\"%s/%s\"><img border=\"0\" src=\"/swat/%s\" alt=\"%s\"></A>\n", - cgi_baseurl(), hlink, src, name); + if ( strcmp(page, id)==0 ) { + printf(" <img src=\"/swat/images/%s_flat.png\" alt=\"%s\" />\n", + id, name); + } else { + printf(" <a href=\"%s/%s\" onmouseover=\"swapImg('%s','%sOver')\" onmouseout=\"swapImg('%s','%sLink')\"><img src=\"/swat/images/%s_link.png\" name=\"%s\" alt=\"%s\" /></a>\n", + cgi_baseurl(), id, id, id, id, id, id, id, name); + } } /**************************************************************************** display the main navigation controls at the top of each page along with a title ****************************************************************************/ -static void show_main_buttons(void) +static void show_main_buttons(const char *page) { char *p; - if ((p = cgi_user_name()) && strcmp(p, "root")) { - printf(_("Logged in as <b>%s</b>"), p); - printf("<p>\n"); - } + printf(" <div id=\"nav\">\n"); - 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"); + rollover_link(_("Configure"), "conf", page); + rollover_link(_("Services"), "services", page); } - /* root always gets all buttons, otherwise look for -P */ + + /* root always gets all buttons, otherwise look for -P */ if ( have_write_access || (!passwd_only && have_read_access) ) { - image_link(_("Status"), "status", "images/status.gif"); - image_link(_("View Config"), "viewconfig", "images/viewconfig.gif"); + rollover_link(_("Status"), "status", page); + } + rollover_link(_("Password Management"), "passwd", page); + + printf(" </div>\n\n"); + + /* Wrap the rest in a control div */ + printf(" <div id=\"controls\">\n\n"); + + if ((p = cgi_user_name()) && strcmp(p, "root")) { + printf(_("Logged in as <b>%s</b>"), p); + printf("<p>\n"); } - image_link(_("Password Management"), "passwd", "images/passwd.gif"); - printf("<HR>\n"); } /**************************************************************************** @@ -576,11 +584,47 @@ static void ViewModeBoxes(int mode) } /**************************************************************************** - display a welcome page + display a welcome page (Read-only users under passwd only get a unique welcome) ****************************************************************************/ static void welcome_page(void) { - include_html("help/welcome.html"); + if (passwd_only && !have_write_access) { + include_html("help/welcome_passwd_only.html"); + } else { + include_html("help/welcome.html"); + } +} + +/**************************************************************************** + display help page +****************************************************************************/ +static void help_page(void) +{ + include_html("help/docs.html"); +} + +/**************************************************************************** + display shares and printers links from an overall services page +****************************************************************************/ +static void services_page(void) +{ + printf(" <div class=\"whereto\">\n"); + printf(" <h2>File and Printer Shares</h2>\n\n"); + printf(" <p>Follow the links below to edit service-level parameters for file and printer shares.</p>\n"); + printf(" </div>\n\n"); + + printf(" <div class=\"view_conf\"><a href=\"viewconfig\" onclick=\"openHelp(this.href); return false\">View smb.conf file</a></div>\n\n"); + + printf(" <div class=\"services_opts\">\n"); + printf(" <ul>\n"); + printf(" <li><a href=\"shares\">File Shares</a></li>\n"); + printf(" <li><a href=\"printers\">Printer Shares</a></li>\n"); + printf(" </ul>\n"); + printf(" </div>\n\n"); + + printf(" <div>\n"); + printf(" <p>Shares may also be added via the links above.</p>\n"); + printf(" </div>\n\n"); } /**************************************************************************** @@ -648,7 +692,9 @@ static void rewritecfg_file(void) { commit_parameters(GLOBAL_SECTION_SNUM); save_reload(0); - printf("<H2>%s</H2>\n", _("Note: smb.conf file has been read and rewritten")); + printf("<h2>Samba Configuration Saved</h2>"); + printf("<p>%s</p>\n", _("Note: smb.conf file has been read and rewritten")); + printf("<p>Return to the <a href=\"javascript:history.go(-1)\">previous page</a>.\n"); } /**************************************************************************** @@ -760,7 +806,7 @@ static void wizard_page(void) printf("<form method=post action=wizard>\n"); if (have_write_access) { - printf("%s\n", _("The \"Rewrite smb.conf file\" button will clear the smb.conf file of all default values and of comments.")); + printf("%s\n", _("The "Rewrite smb.conf file" button will clear the smb.conf file of all default values and of comments.")); printf("%s", _("The same will happen if you press the commit button.")); printf("<br><br>\n"); printf("<center>"); @@ -820,14 +866,19 @@ static void wizard_page(void) /**************************************************************************** - display a globals editing page + display a conf page for editing global parameters ****************************************************************************/ -static void globals_page(void) +static void conf_page(void) { unsigned int parm_filter = FLAG_BASIC; int mode = 0; - printf("<H2>%s</H2>\n", _("Global Parameters")); + printf(" <div class=\"whereto\">\n"); + printf(" <h2>Configuring Samba</h2>\n\n"); + printf(" <p>The following menu allows for editing of global parameters affecting your Samba configuration.</p>\n"); + printf(" </div>\n\n"); + + printf(" <div class=\"view_conf\"><a href=\"viewconfig\" onclick=\"openHelp(this.href); return false\">View smb.conf file</a></div>\n\n"); if (cgi_variable("Commit")) { commit_parameters(GLOBAL_SECTION_SNUM); @@ -841,7 +892,7 @@ static void globals_page(void) if ( cgi_variable("AdvMode")) mode = 1; - printf("<form name=\"swatform\" method=post action=globals>\n"); + printf("<form name=\"swatform\" method=post action=conf>\n"); ViewModeBoxes( mode ); switch ( mode ) { @@ -885,6 +936,8 @@ static void shares_page(void) snum = lp_servicenumber(share); printf("<H2>%s</H2>\n", _("Share Parameters")); + + printf(" <div class=\"view_conf\"><a href=\"services\">Return to Services Page</a><a href=\"viewconfig\" onclick=\"openHelp(this.href); return false\">View smb.conf file</a></div>\n\n"); if (cgi_variable("Commit") && snum >= 0) { commit_parameters(snum); @@ -1226,6 +1279,8 @@ static void printers_page(void) snum = lp_servicenumber(share); printf("<H2>%s</H2>\n", _("Printer Parameters")); + + printf(" <div class=\"view_conf\"><a href=\"services\">Return to Services Page</a><a href=\"viewconfig\" onclick=\"openHelp(this.href); return false\">View smb.conf file</a></div>\n\n"); printf("<H3>%s</H3>\n", _("Important Note:")); printf(_("Printer names marked with [*] in the Choose Printer drop-down box ")); @@ -1395,29 +1450,32 @@ static void printers_page(void) have_read_access = (access(dyn_CONFIGFILE,R_OK) == 0); } - show_main_buttons(); - page = cgi_pathinfo(); - /* Root gets full functionality */ - if (have_read_access && strcmp(page, "globals")==0) { - globals_page(); + show_main_buttons(page); + + if (have_read_access && strcmp(page,"conf")==0) { + conf_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 (have_read_access && strcmp(page,"services")==0) { + services_page(); } else if (have_read_access && strcmp(page,"shares")==0) { 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,"rewritecfg")==0) { - rewritecfg_file(); + } else if (have_read_access && strcmp(page,"help")==0) { + help_page(); } else { welcome_page(); } |