diff options
-rw-r--r-- | source3/web/diagnose.c | 17 | ||||
-rw-r--r-- | source3/web/neg_lang.c | 62 | ||||
-rw-r--r-- | source3/web/startstop.c | 33 | ||||
-rw-r--r-- | source3/web/statuspage.c | 28 | ||||
-rw-r--r-- | source3/web/swat.c | 16 |
5 files changed, 142 insertions, 14 deletions
diff --git a/source3/web/diagnose.c b/source3/web/diagnose.c index e822474aab..396499bcb9 100644 --- a/source3/web/diagnose.c +++ b/source3/web/diagnose.c @@ -21,6 +21,23 @@ #include "includes.h" #include "../web/swat_proto.h" +#ifdef WITH_WINBIND + +NSS_STATUS winbindd_request(int req_type, + struct winbindd_request *request, + struct winbindd_response *response); + +/* check to see if winbind is running by pinging it */ + +BOOL winbindd_running(void) +{ + + if (winbindd_request(WINBINDD_PING, NULL, NULL)) + return False; + + return True; +} +#endif /* check to see if nmbd is running on localhost by looking for a __SAMBA__ response */ diff --git a/source3/web/neg_lang.c b/source3/web/neg_lang.c index 88bc5498e9..da974f78a4 100644 --- a/source3/web/neg_lang.c +++ b/source3/web/neg_lang.c @@ -48,20 +48,70 @@ int web_open(const char *fname, int flags, mode_t mode) } +struct pri_list { + float pri; + char *string; +}; + +static int qsort_cmp_list(const void *x, const void *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; +} + /* choose from a list of languages. The list can be comma or space separated Keep choosing until we get a hit + Changed to habdle priority -- Simo */ -void web_set_lang(const char *lang_list) + +void web_set_lang(const char *lang_string) { - fstring lang; - char *p = (char *)lang_list; + char **lang_list, **count; + struct pri_list *pl; + int lang_num, i; + + /* build the lang list */ + lang_list = str_list_make(lang_string, ", \t\r\n"); + if (!lang_list) return; - while (next_token(&p, lang, ", \t\r\n", sizeof(lang))) { - if (lang_tdb_init(lang)) return; + /* sort the list by priority */ + lang_num = 0; + count = lang_list; + while (*count && **count) { + count++; + lang_num++; } - + pl = (struct pri_list *)malloc(sizeof(struct pri_list) * lang_num); + for (i = 0; i < lang_num; i++) { + char *pri_code; + if ((pri_code=strstr(lang_list[i], ";q="))) { + *pri_code = '\0'; + pri_code += 3; + sscanf(pri_code, "%f", &(pl[i].pri)); + } else { + pl[i].pri = 1; + } + pl[i].string = strdup(lang_list[i]); + } + str_list_free(&lang_list); + + qsort(pl, lang_num, sizeof(struct pri_list), &qsort_cmp_list); + /* it's not an error to not initialise - we just fall back to the default */ + + for (i = 0; i < lang_num; i++) { + if (lang_tdb_init(pl[i].string)) break; + } + + for (i = 0; i < lang_num; i++) { + SAFE_FREE(pl[i].string); + } + SAFE_FREE(pl); + + return; } diff --git a/source3/web/startstop.c b/source3/web/startstop.c index 893784dd55..e10dff4118 100644 --- a/source3/web/startstop.c +++ b/source3/web/startstop.c @@ -67,6 +67,27 @@ void start_nmbd(void) exit(0); } +/** Startup winbindd from web interface. */ +void start_winbindd(void) +{ + pstring binfile; + + if (geteuid() != 0) return; + + if (fork()) { + sleep(SLEEP_TIME); + return; + } + + slprintf(binfile, sizeof(pstring) - 1, "%s/winbindd", dyn_SBINDIR); + + become_daemon(); + + execl(binfile, binfile, NULL); + + exit(0); +} + /* stop smbd */ void stop_smbd(void) @@ -91,7 +112,19 @@ void stop_nmbd(void) kill(pid, SIGTERM); } +#ifdef WITH_WINBIND +/* stop winbindd */ +void stop_winbindd(void) +{ + pid_t pid = pidfile_pid("winbindd"); + if (geteuid() != 0) return; + + if (pid <= 0) return; + + kill(pid, SIGTERM); +} +#endif /* kill a specified process */ void kill_pid(pid_t pid) { diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 792e077a61..3b597d44c0 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -248,6 +248,20 @@ void status_page(void) stop_nmbd(); } +#ifdef WITH_WINBIND + if (cgi_variable("winbindd_restart")) { + stop_winbindd(); + start_winbindd(); + } + + if (cgi_variable("winbindd_start")) { + start_winbindd(); + } + + if (cgi_variable("winbindd_stop")) { + stop_winbindd(); + } +#endif if (cgi_variable("autorefresh")) { autorefresh = 1; } else if (cgi_variable("norefresh")) { @@ -320,6 +334,20 @@ void status_page(void) } d_printf("</tr>\n"); +#ifdef WITH_WINBIND + fflush(stdout); + d_printf("<tr><td>%s</td><td>%s</td>\n", _("winbindd:"), winbindd_running()?_("running"):_("not running")); + if (geteuid() == 0) { + if (winbindd_running()) { + d_printf("<td><input type=submit name=\"winbindd_stop\" value=\"%s\"></td>\n", _("Stop winbindd")); + } else { + d_printf("<td><input type=submit name=\"winbindd_start\" value=\"%s\"></td>\n", _("Start winbindd")); + } + d_printf("<td><input type=submit name=\"winbindd_restart\" value=\"%s\"></td>\n", _("Restart winbindd")); + } + d_printf("</tr>\n"); +#endif + d_printf("</table>\n"); fflush(stdout); diff --git a/source3/web/swat.c b/source3/web/swat.c index 7be46790db..80d3232d2b 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -79,15 +79,15 @@ static char *fix_backslash(char *str) return newstring; } -static char *stripspace(char *str) +static char *stripspaceupper(char *str) { -static char newstring[1024]; -char *p = newstring; + static char newstring[1024]; + char *p = newstring; - while (*str) { - if (*str != ' ') *p++ = *str; - ++str; - } + while (*str) { + if (*str != ' ') *p++ = toupper(*str); + ++str; + } *p = '\0'; return newstring; } @@ -200,7 +200,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(stripspace(parm->label), _("Help"), parm->label)); + printf("<tr><td>%s</td><td>", get_parm_translated(stripspaceupper(parm->label), _("Help"), parm->label)); switch (parm->type) { case P_CHAR: d_printf("<input type=text size=2 name=\"parm_%s\" value=\"%c\">", |