関数 | |
static int | enum_index (int value, const struct enum_list *enumlist) |
static char * | fix_backslash (const char *str) |
static char * | fix_quotes (const char *str) |
static char * | stripspaceupper (const char *str) |
static char * | make_parm_name (const char *label) |
static int | include_html (const char *fname) |
static void | print_header (void) |
static const char * | get_parm_translated (const char *pAnchor, const char *pHelp, const char *pLabel) |
static void | print_footer (void) |
static void | show_parameter (int snum, struct parm_struct *parm) |
static void | show_parameters (int snum, int allparameters, unsigned int parm_filter, int printers) |
static BOOL | load_config (BOOL save_def) |
static void | write_config (FILE *f, BOOL show_defaults) |
static int | save_reload (int snum) |
static void | commit_parameter (int snum, struct parm_struct *parm, const char *v) |
static void | commit_parameters (int snum) |
static void | image_link (const char *name, const char *hlink, const char *src) |
static void | show_main_buttons (void) |
static void | ViewModeBoxes (int mode) |
static void | welcome_page (void) |
static void | viewconfig_page (void) |
static void | wizard_params_page (void) |
static void | rewritecfg_file (void) |
static void | wizard_page (void) |
static void | globals_page (void) |
static void | shares_page (void) |
static BOOL | change_password (const char *remote_machine, const char *user_name, const char *old_passwd, const char *new_passwd, int local_flags) |
static void | chg_passwd (void) |
static void | passwd_page (void) |
static void | printers_page (void) |
int | main (int argc, char *argv[]) |
main function for SWAT. | |
変数 | |
static BOOL | demo_mode = False |
static BOOL | passwd_only = False |
static BOOL | have_write_access = False |
static BOOL | have_read_access = False |
static int | iNumNonAutoPrintServices = 0 |
swat.c で定義されています。
static int enum_index | ( | int | value, | |
const struct enum_list * | enumlist | |||
) | [static] |
参照先 enum_list::name.
参照元 show_parameter().
00059 { 00060 int i; 00061 for (i=0;enumlist[i].name;i++) 00062 if (value == enumlist[i].value) break; 00063 return(i); 00064 }
static char* fix_backslash | ( | const char * | str | ) | [static] |
参照元 show_parameter().
00067 { 00068 static char newstring[1024]; 00069 char *p = newstring; 00070 00071 while (*str) { 00072 if (*str == '\\') {*p++ = '\\';*p++ = '\\';} 00073 else *p++ = *str; 00074 ++str; 00075 } 00076 *p = '\0'; 00077 return newstring; 00078 }
static char* fix_quotes | ( | const char * | str | ) | [static] |
参照元 show_parameter().
00081 { 00082 static pstring newstring; 00083 char *p = newstring; 00084 size_t newstring_len = sizeof(newstring); 00085 int quote_len = strlen("""); 00086 00087 while (*str) { 00088 if ( *str == '\"' && (newstring_len - PTR_DIFF(p, newstring) - 1) > quote_len ) { 00089 strncpy( p, """, quote_len); 00090 p += quote_len; 00091 } else { 00092 *p++ = *str; 00093 } 00094 ++str; 00095 } 00096 *p = '\0'; 00097 return newstring; 00098 }
static char* stripspaceupper | ( | const char * | str | ) | [static] |
参照先 toupper_ascii().
参照元 show_parameter().
00101 { 00102 static char newstring[1024]; 00103 char *p = newstring; 00104 00105 while (*str) { 00106 if (*str != ' ') *p++ = toupper_ascii(*str); 00107 ++str; 00108 } 00109 *p = '\0'; 00110 return newstring; 00111 }
static char* make_parm_name | ( | const char * | label | ) | [static] |
参照元 commit_parameters()・show_parameter().
00114 { 00115 static char parmname[1024]; 00116 char *p = parmname; 00117 00118 while (*label) { 00119 if (*label == ' ') *p++ = '_'; 00120 else *p++ = *label; 00121 ++label; 00122 } 00123 *p = '\0'; 00124 return parmname; 00125 }
static int include_html | ( | const char * | fname | ) | [static] |
参照先 buf・fd・printf()・web_open().
参照元 print_footer()・print_header()・welcome_page().
00131 { 00132 int fd; 00133 char buf[1024]; 00134 int ret; 00135 00136 fd = web_open(fname, O_RDONLY, 0); 00137 00138 if (fd == -1) { 00139 printf(_("ERROR: Can't open %s"), fname); 00140 printf("\n"); 00141 return 0; 00142 } 00143 00144 while ((ret = read(fd, buf, sizeof(buf))) > 0) { 00145 write(1, buf, ret); 00146 } 00147 00148 close(fd); 00149 return 1; 00150 }
static void print_header | ( | void | ) | [static] |
参照先 cgi_waspost()・include_html()・printf().
参照元 main().
00156 { 00157 if (!cgi_waspost()) { 00158 printf("Expires: 0\r\n"); 00159 } 00160 printf("Content-type: text/html\r\n\r\n"); 00161 00162 if (!include_html("include/header.html")) { 00163 printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"); 00164 printf("<HTML>\n<HEAD>\n<TITLE>Samba Web Administration Tool</TITLE>\n</HEAD>\n<BODY background=\"/swat/images/background.jpg\">\n\n"); 00165 } 00166 }
static const char* get_parm_translated | ( | const char * | pAnchor, | |
const char * | pHelp, | |||
const char * | pLabel | |||
) | [static] |
参照先 pstr_sprintf().
参照元 show_parameter().
00185 { 00186 const char* pTranslated = _(pLabel); 00187 static pstring output; 00188 if(strcmp(pLabel, pTranslated) != 0) 00189 { 00190 pstr_sprintf(output, 00191 "<A HREF=\"/swat/help/manpages/smb.conf.5.html#%s\" target=\"docs\"> %s</A> %s <br><span class=\"i18n_translated_parm\">%s</span>", 00192 pAnchor, pHelp, pLabel, pTranslated); 00193 return output; 00194 } 00195 pstr_sprintf(output, 00196 "<A HREF=\"/swat/help/manpages/smb.conf.5.html#%s\" target=\"docs\"> %s</A> %s", 00197 pAnchor, pHelp, pLabel); 00198 return output; 00199 }
static void print_footer | ( | void | ) | [static] |
参照先 include_html()・printf().
参照元 main().
00204 { 00205 if (!include_html("include/footer.html")) { 00206 printf("\n</BODY>\n</HTML>\n"); 00207 } 00208 }
static void show_parameter | ( | int | snum, | |
struct parm_struct * | parm | |||
) | [static] |
参照先 parm_struct::bvalue・parm_struct::cvalue・parm_struct::def・enum_index()・parm_struct::enum_list・fix_backslash()・fix_quotes()・get_parm_translated()・parm_struct::ivalue・parm_struct::label・list()・lp_local_ptr()・parm_struct::lvalue・make_parm_name()・enum_list::name・octal_string()・P_BOOL・P_BOOLREV・P_CHAR・parm_struct::p_class・P_ENUM・P_GSTRING・P_INTEGER・P_LIST・P_LOCAL・P_OCTAL・P_SEP・P_STRING・P_UGSTRING・P_USTRING・printf()・parm_struct::ptr・push_utf8_allocate()・strchr_m()・stripspaceupper()・parm_struct::svalue・parm_struct::type・enum_list::value.
参照元 show_parameters().
00214 { 00215 int i; 00216 void *ptr = parm->ptr; 00217 char *utf8_s1, *utf8_s2; 00218 00219 if (parm->p_class == P_LOCAL && snum >= 0) { 00220 ptr = lp_local_ptr(snum, ptr); 00221 } 00222 00223 printf("<tr><td>%s</td><td>", get_parm_translated(stripspaceupper(parm->label), _("Help"), parm->label)); 00224 switch (parm->type) { 00225 case P_CHAR: 00226 printf("<input type=text size=2 name=\"parm_%s\" value=\"%c\">", 00227 make_parm_name(parm->label), *(char *)ptr); 00228 printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%c\'\">", 00229 _("Set Default"), make_parm_name(parm->label),(char)(parm->def.cvalue)); 00230 break; 00231 00232 case P_LIST: 00233 printf("<input type=text size=40 name=\"parm_%s\" value=\"", 00234 make_parm_name(parm->label)); 00235 if ((char ***)ptr && *(char ***)ptr && **(char ***)ptr) { 00236 char **list = *(char ***)ptr; 00237 for (;*list;list++) { 00238 /* enclose in HTML encoded quotes if the string contains a space */ 00239 if ( strchr_m(*list, ' ') ) { 00240 push_utf8_allocate(&utf8_s1, *list); 00241 push_utf8_allocate(&utf8_s2, ((*(list+1))?", ":"")); 00242 printf(""%s"%s", utf8_s1, utf8_s2); 00243 } else { 00244 push_utf8_allocate(&utf8_s1, *list); 00245 push_utf8_allocate(&utf8_s2, ((*(list+1))?", ":"")); 00246 printf("%s%s", utf8_s1, utf8_s2); 00247 } 00248 SAFE_FREE(utf8_s1); 00249 SAFE_FREE(utf8_s2); 00250 } 00251 } 00252 printf("\">"); 00253 printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'", 00254 _("Set Default"), make_parm_name(parm->label)); 00255 if (parm->def.lvalue) { 00256 char **list = (char **)(parm->def.lvalue); 00257 for (; *list; list++) { 00258 /* enclose in HTML encoded quotes if the string contains a space */ 00259 if ( strchr_m(*list, ' ') ) 00260 printf(""%s"%s", *list, ((*(list+1))?", ":"")); 00261 else 00262 printf("%s%s", *list, ((*(list+1))?", ":"")); 00263 } 00264 } 00265 printf("\'\">"); 00266 break; 00267 00268 case P_STRING: 00269 case P_USTRING: 00270 push_utf8_allocate(&utf8_s1, *(char **)ptr); 00271 printf("<input type=text size=40 name=\"parm_%s\" value=\"%s\">", 00272 make_parm_name(parm->label), fix_quotes(utf8_s1)); 00273 SAFE_FREE(utf8_s1); 00274 printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%s\'\">", 00275 _("Set Default"), make_parm_name(parm->label),fix_backslash((char *)(parm->def.svalue))); 00276 break; 00277 00278 case P_GSTRING: 00279 case P_UGSTRING: 00280 push_utf8_allocate(&utf8_s1, (char *)ptr); 00281 printf("<input type=text size=40 name=\"parm_%s\" value=\"%s\">", 00282 make_parm_name(parm->label), fix_quotes(utf8_s1)); 00283 SAFE_FREE(utf8_s1); 00284 printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%s\'\">", 00285 _("Set Default"), make_parm_name(parm->label),fix_backslash((char *)(parm->def.svalue))); 00286 break; 00287 00288 case P_BOOL: 00289 printf("<select name=\"parm_%s\">",make_parm_name(parm->label)); 00290 printf("<option %s>Yes", (*(BOOL *)ptr)?"selected":""); 00291 printf("<option %s>No", (*(BOOL *)ptr)?"":"selected"); 00292 printf("</select>"); 00293 printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.selectedIndex=\'%d\'\">", 00294 _("Set Default"), make_parm_name(parm->label),(BOOL)(parm->def.bvalue)?0:1); 00295 break; 00296 00297 case P_BOOLREV: 00298 printf("<select name=\"parm_%s\">",make_parm_name(parm->label)); 00299 printf("<option %s>Yes", (*(BOOL *)ptr)?"":"selected"); 00300 printf("<option %s>No", (*(BOOL *)ptr)?"selected":""); 00301 printf("</select>"); 00302 printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.selectedIndex=\'%d\'\">", 00303 _("Set Default"), make_parm_name(parm->label),(BOOL)(parm->def.bvalue)?1:0); 00304 break; 00305 00306 case P_INTEGER: 00307 printf("<input type=text size=8 name=\"parm_%s\" value=\"%d\">", make_parm_name(parm->label), *(int *)ptr); 00308 printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%d\'\">", 00309 _("Set Default"), make_parm_name(parm->label),(int)(parm->def.ivalue)); 00310 break; 00311 00312 case P_OCTAL: 00313 printf("<input type=text size=8 name=\"parm_%s\" value=%s>", make_parm_name(parm->label), octal_string(*(int *)ptr)); 00314 printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%s\'\">", 00315 _("Set Default"), make_parm_name(parm->label), 00316 octal_string((int)(parm->def.ivalue))); 00317 break; 00318 00319 case P_ENUM: 00320 printf("<select name=\"parm_%s\">",make_parm_name(parm->label)); 00321 for (i=0;parm->enum_list[i].name;i++) { 00322 if (i == 0 || parm->enum_list[i].value != parm->enum_list[i-1].value) { 00323 printf("<option %s>%s",(*(int *)ptr)==parm->enum_list[i].value?"selected":"",parm->enum_list[i].name); 00324 } 00325 } 00326 printf("</select>"); 00327 printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.selectedIndex=\'%d\'\">", 00328 _("Set Default"), make_parm_name(parm->label),enum_index((int)(parm->def.ivalue),parm->enum_list)); 00329 break; 00330 case P_SEP: 00331 break; 00332 } 00333 printf("</td></tr>\n"); 00334 }
static void show_parameters | ( | int | snum, | |
int | allparameters, | |||
unsigned int | parm_filter, | |||
int | printers | |||
) | [static] |
参照先 parm_struct::bvalue・parm_struct::cvalue・parm_struct::def・parm_struct::flags・parm_struct::ivalue・parm_struct::label・lp_local_ptr()・lp_next_parameter()・parm_struct::lvalue・P_BOOL・P_BOOLREV・P_CHAR・parm_struct::p_class・P_ENUM・P_GSTRING・P_INTEGER・P_LIST・P_LOCAL・P_OCTAL・P_SEP・P_SEPARATOR・P_STRING・P_UGSTRING・P_USTRING・printf()・parm_struct::ptr・show_parameter()・str_list_compare()・parm_struct::svalue・parm_struct::type.
参照元 globals_page()・printers_page()・shares_page()・wizard_params_page().
00340 { 00341 int i = 0; 00342 struct parm_struct *parm; 00343 const char *heading = NULL; 00344 const char *last_heading = NULL; 00345 00346 while ((parm = lp_next_parameter(snum, &i, allparameters))) { 00347 if (snum < 0 && parm->p_class == P_LOCAL && !(parm->flags & FLAG_GLOBAL)) 00348 continue; 00349 if (parm->p_class == P_SEPARATOR) { 00350 heading = parm->label; 00351 continue; 00352 } 00353 if (parm->flags & FLAG_HIDE) continue; 00354 if (snum >= 0) { 00355 if (printers & !(parm->flags & FLAG_PRINT)) continue; 00356 if (!printers & !(parm->flags & FLAG_SHARE)) continue; 00357 } 00358 00359 if (!( parm_filter & FLAG_ADVANCED )) { 00360 if (!(parm->flags & FLAG_BASIC)) { 00361 void *ptr = parm->ptr; 00362 00363 if (parm->p_class == P_LOCAL && snum >= 0) { 00364 ptr = lp_local_ptr(snum, ptr); 00365 } 00366 00367 switch (parm->type) { 00368 case P_CHAR: 00369 if (*(char *)ptr == (char)(parm->def.cvalue)) continue; 00370 break; 00371 00372 case P_LIST: 00373 if (!str_list_compare(*(char ***)ptr, (char **)(parm->def.lvalue))) continue; 00374 break; 00375 00376 case P_STRING: 00377 case P_USTRING: 00378 if (!strcmp(*(char **)ptr,(char *)(parm->def.svalue))) continue; 00379 break; 00380 00381 case P_GSTRING: 00382 case P_UGSTRING: 00383 if (!strcmp((char *)ptr,(char *)(parm->def.svalue))) continue; 00384 break; 00385 00386 case P_BOOL: 00387 case P_BOOLREV: 00388 if (*(BOOL *)ptr == (BOOL)(parm->def.bvalue)) continue; 00389 break; 00390 00391 case P_INTEGER: 00392 case P_OCTAL: 00393 if (*(int *)ptr == (int)(parm->def.ivalue)) continue; 00394 break; 00395 00396 00397 case P_ENUM: 00398 if (*(int *)ptr == (int)(parm->def.ivalue)) continue; 00399 break; 00400 case P_SEP: 00401 continue; 00402 } 00403 } 00404 if (printers && !(parm->flags & FLAG_PRINT)) continue; 00405 } 00406 00407 if ((parm_filter & FLAG_WIZARD) && !(parm->flags & FLAG_WIZARD)) continue; 00408 00409 if ((parm_filter & FLAG_ADVANCED) && !(parm->flags & FLAG_ADVANCED)) continue; 00410 00411 if (heading && heading != last_heading) { 00412 printf("<tr><td></td></tr><tr><td><b><u>%s</u></b></td></tr>\n", _(heading)); 00413 last_heading = heading; 00414 } 00415 show_parameter(snum, parm); 00416 } 00417 }
参照先 dyn_CONFIGFILE.
参照元 main()・printers_page()・save_reload()・shares_page()・wizard_page().
00423 { 00424 lp_resetnumservices(); 00425 return lp_load(dyn_CONFIGFILE,False,save_def,False,True); 00426 }
static void write_config | ( | FILE * | f, | |
BOOL | show_defaults | |||
) | [static] |
参照先 cgi_remote_addr()・cgi_remote_host()・current_timestring()・fprintf()・iNumNonAutoPrintServices.
参照元 save_reload()・viewconfig_page().
00432 { 00433 fprintf(f, "# Samba config file created using SWAT\n"); 00434 fprintf(f, "# from %s (%s)\n", cgi_remote_host(), cgi_remote_addr()); 00435 fprintf(f, "# Date: %s\n\n", current_timestring(False)); 00436 00437 lp_dump(f, show_defaults, iNumNonAutoPrintServices); 00438 }
static int save_reload | ( | int | snum | ) | [static] |
参照先 dyn_CONFIGFILE・iNumNonAutoPrintServices・load_config()・load_printers()・lp_killunused()・printf()・sys_fopen()・write_config().
参照元 globals_page()・printers_page()・rewritecfg_file()・shares_page()・wizard_page()・wizard_params_page().
00444 { 00445 FILE *f; 00446 struct stat st; 00447 00448 f = sys_fopen(dyn_CONFIGFILE,"w"); 00449 if (!f) { 00450 printf(_("failed to open %s for writing"), dyn_CONFIGFILE); 00451 printf("\n"); 00452 return 0; 00453 } 00454 00455 /* just in case they have used the buggy xinetd to create the file */ 00456 if (fstat(fileno(f), &st) == 0 && 00457 (st.st_mode & S_IWOTH)) { 00458 #if defined HAVE_FCHMOD 00459 fchmod(fileno(f), S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); 00460 #else 00461 chmod(dyn_CONFIGFILE, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); 00462 #endif 00463 } 00464 00465 write_config(f, False); 00466 if (snum) 00467 lp_dump_one(f, False, snum); 00468 fclose(f); 00469 00470 lp_killunused(NULL); 00471 00472 if (!load_config(False)) { 00473 printf(_("Can't reload %s"), dyn_CONFIGFILE); 00474 printf("\n"); 00475 return 0; 00476 } 00477 iNumNonAutoPrintServices = lp_numservices(); 00478 load_printers(); 00479 00480 return 1; 00481 }
static void commit_parameter | ( | int | snum, | |
struct parm_struct * | parm, | |||
const char * | v | |||
) | [static] |
参照先 parm_struct::label・lp_do_parameter()・lp_is_default()・P_LOCAL.
参照元 commit_parameters().
00487 { 00488 int i; 00489 char *s; 00490 00491 if (snum < 0 && parm->p_class == P_LOCAL) { 00492 /* this handles the case where we are changing a local 00493 variable globally. We need to change the parameter in 00494 all shares where it is currently set to the default */ 00495 for (i=0;i<lp_numservices();i++) { 00496 s = lp_servicename(i); 00497 if (s && (*s) && lp_is_default(i, parm)) { 00498 lp_do_parameter(i, parm->label, v); 00499 } 00500 } 00501 } 00502 00503 lp_do_parameter(snum, parm->label, v); 00504 }
static void commit_parameters | ( | int | snum | ) | [static] |
参照先 cgi_variable()・commit_parameter()・parm_struct::flags・parm_struct::label・lp_next_parameter()・make_parm_name().
参照元 globals_page()・printers_page()・rewritecfg_file()・shares_page()・wizard_page()・wizard_params_page().
00510 { 00511 int i = 0; 00512 struct parm_struct *parm; 00513 pstring label; 00514 const char *v; 00515 00516 while ((parm = lp_next_parameter(snum, &i, 1))) { 00517 slprintf(label, sizeof(label)-1, "parm_%s", make_parm_name(parm->label)); 00518 if ((v = cgi_variable(label)) != NULL) { 00519 if (parm->flags & FLAG_HIDE) continue; 00520 commit_parameter(snum, parm, v); 00521 } 00522 } 00523 }
static void image_link | ( | const char * | name, | |
const char * | hlink, | |||
const char * | src | |||
) | [static] |
参照先 cgi_baseurl()・printf().
参照元 show_main_buttons().
00529 { 00530 printf("<A HREF=\"%s/%s\"><img border=\"0\" src=\"/swat/%s\" alt=\"%s\"></A>\n", 00531 cgi_baseurl(), hlink, src, name); 00532 }
static void show_main_buttons | ( | void | ) | [static] |
参照先 cgi_user_name()・have_read_access・have_write_access・image_link()・passwd_only・printf().
参照元 main().
00539 { 00540 char *p; 00541 00542 if ((p = cgi_user_name()) && strcmp(p, "root")) { 00543 printf(_("Logged in as <b>%s</b>"), p); 00544 printf("<p>\n"); 00545 } 00546 00547 image_link(_("Home"), "", "images/home.gif"); 00548 if (have_write_access) { 00549 image_link(_("Globals"), "globals", "images/globals.gif"); 00550 image_link(_("Shares"), "shares", "images/shares.gif"); 00551 image_link(_("Printers"), "printers", "images/printers.gif"); 00552 image_link(_("Wizard"), "wizard", "images/wizard.gif"); 00553 } 00554 /* root always gets all buttons, otherwise look for -P */ 00555 if ( have_write_access || (!passwd_only && have_read_access) ) { 00556 image_link(_("Status"), "status", "images/status.gif"); 00557 image_link(_("View Config"), "viewconfig", "images/viewconfig.gif"); 00558 } 00559 image_link(_("Password Management"), "passwd", "images/passwd.gif"); 00560 00561 printf("<HR>\n"); 00562 }
static void ViewModeBoxes | ( | int | mode | ) | [static] |
参照先 printf().
参照元 globals_page()・printers_page()・shares_page().
00568 { 00569 printf("<p>%s: \n", _("Current View Is")); 00570 printf("<input type=radio name=\"ViewMode\" value=0 %s>%s\n", ((mode == 0) ? "checked" : ""), _("Basic")); 00571 printf("<input type=radio name=\"ViewMode\" value=1 %s>%s\n", ((mode == 1) ? "checked" : ""), _("Advanced")); 00572 printf("<br>%s: \n", _("Change View To")); 00573 printf("<input type=submit name=\"BasicMode\" value=\"%s\">\n", _("Basic")); 00574 printf("<input type=submit name=\"AdvMode\" value=\"%s\">\n", _("Advanced")); 00575 printf("</p><br>\n"); 00576 }
static void welcome_page | ( | void | ) | [static] |
参照先 file_exist()・include_html().
参照元 main().
00582 { 00583 if (file_exist("help/welcome.html", NULL)) { 00584 include_html("help/welcome.html"); 00585 } else { 00586 include_html("help/welcome-no-samba-doc.html"); 00587 } 00588 }
static void viewconfig_page | ( | void | ) | [static] |
参照先 cgi_variable()・printf()・write_config().
参照元 main().
00594 { 00595 int full_view=0; 00596 00597 if (cgi_variable("full_view")) { 00598 full_view = 1; 00599 } 00600 00601 printf("<H2>%s</H2>\n", _("Current Config")); 00602 printf("<form method=post>\n"); 00603 00604 if (full_view) { 00605 printf("<input type=submit name=\"normal_view\" value=\"%s\">\n", _("Normal View")); 00606 } else { 00607 printf("<input type=submit name=\"full_view\" value=\"%s\">\n", _("Full View")); 00608 } 00609 00610 printf("<p><pre>"); 00611 write_config(stdout, full_view); 00612 printf("</pre>"); 00613 printf("</form>\n"); 00614 }
static void wizard_params_page | ( | void | ) | [static] |
参照先 cgi_variable()・commit_parameters()・have_write_access・printf()・save_reload()・show_parameters().
参照元 main()・wizard_page().
00620 { 00621 unsigned int parm_filter = FLAG_WIZARD; 00622 00623 /* Here we first set and commit all the parameters that were selected 00624 in the previous screen. */ 00625 00626 printf("<H2>%s</H2>\n", _("Wizard Parameter Edit Page")); 00627 00628 if (cgi_variable("Commit")) { 00629 commit_parameters(GLOBAL_SECTION_SNUM); 00630 save_reload(0); 00631 } 00632 00633 printf("<form name=\"swatform\" method=post action=wizard_params>\n"); 00634 00635 if (have_write_access) { 00636 printf("<input type=submit name=\"Commit\" value=\"Commit Changes\">\n"); 00637 } 00638 00639 printf("<input type=reset name=\"Reset Values\" value=\"Reset\">\n"); 00640 printf("<p>\n"); 00641 00642 printf("<table>\n"); 00643 show_parameters(GLOBAL_SECTION_SNUM, 1, parm_filter, 0); 00644 printf("</table>\n"); 00645 printf("</form>\n"); 00646 }
static void rewritecfg_file | ( | void | ) | [static] |
参照先 commit_parameters()・printf()・save_reload().
参照元 main()・wizard_page().
00652 { 00653 commit_parameters(GLOBAL_SECTION_SNUM); 00654 save_reload(0); 00655 printf("<H2>%s</H2>\n", _("Note: smb.conf file has been read and rewritten")); 00656 }
static void wizard_page | ( | void | ) | [static] |
参照先 cgi_variable()・cgi_variable_nonull()・commit_parameters()・have_write_access・iNumNonAutoPrintServices・load_config()・lp_do_parameter()・printf()・rewritecfg_file()・ROLE_DOMAIN_BDC・ROLE_DOMAIN_MEMBER・ROLE_DOMAIN_PDC・ROLE_STANDALONE・save_reload()・wizard_params_page().
参照元 main().
00662 { 00663 /* Set some variables to collect data from smb.conf */ 00664 int role = 0; 00665 int winstype = 0; 00666 int have_home = -1; 00667 int HomeExpo = 0; 00668 int SerType = 0; 00669 00670 if (cgi_variable("Rewrite")) { 00671 (void) rewritecfg_file(); 00672 return; 00673 } 00674 00675 if (cgi_variable("GetWizardParams")){ 00676 (void) wizard_params_page(); 00677 return; 00678 } 00679 00680 if (cgi_variable("Commit")){ 00681 SerType = atoi(cgi_variable_nonull("ServerType")); 00682 winstype = atoi(cgi_variable_nonull("WINSType")); 00683 have_home = lp_servicenumber(HOMES_NAME); 00684 HomeExpo = atoi(cgi_variable_nonull("HomeExpo")); 00685 00686 /* Plain text passwords are too badly broken - use encrypted passwords only */ 00687 lp_do_parameter( GLOBAL_SECTION_SNUM, "encrypt passwords", "Yes"); 00688 00689 switch ( SerType ){ 00690 case 0: 00691 /* Stand-alone Server */ 00692 lp_do_parameter( GLOBAL_SECTION_SNUM, "security", "USER" ); 00693 lp_do_parameter( GLOBAL_SECTION_SNUM, "domain logons", "No" ); 00694 break; 00695 case 1: 00696 /* Domain Member */ 00697 lp_do_parameter( GLOBAL_SECTION_SNUM, "security", "DOMAIN" ); 00698 lp_do_parameter( GLOBAL_SECTION_SNUM, "domain logons", "No" ); 00699 break; 00700 case 2: 00701 /* Domain Controller */ 00702 lp_do_parameter( GLOBAL_SECTION_SNUM, "security", "USER" ); 00703 lp_do_parameter( GLOBAL_SECTION_SNUM, "domain logons", "Yes" ); 00704 break; 00705 } 00706 switch ( winstype ) { 00707 case 0: 00708 lp_do_parameter( GLOBAL_SECTION_SNUM, "wins support", "No" ); 00709 lp_do_parameter( GLOBAL_SECTION_SNUM, "wins server", "" ); 00710 break; 00711 case 1: 00712 lp_do_parameter( GLOBAL_SECTION_SNUM, "wins support", "Yes" ); 00713 lp_do_parameter( GLOBAL_SECTION_SNUM, "wins server", "" ); 00714 break; 00715 case 2: 00716 lp_do_parameter( GLOBAL_SECTION_SNUM, "wins support", "No" ); 00717 lp_do_parameter( GLOBAL_SECTION_SNUM, "wins server", cgi_variable_nonull("WINSAddr")); 00718 break; 00719 } 00720 00721 /* Have to create Homes share? */ 00722 if ((HomeExpo == 1) && (have_home == -1)) { 00723 pstring unix_share; 00724 00725 pstrcpy(unix_share,HOMES_NAME); 00726 load_config(False); 00727 lp_copy_service(GLOBAL_SECTION_SNUM, unix_share); 00728 iNumNonAutoPrintServices = lp_numservices(); 00729 have_home = lp_servicenumber(HOMES_NAME); 00730 lp_do_parameter( have_home, "read only", "No"); 00731 lp_do_parameter( have_home, "valid users", "%S"); 00732 lp_do_parameter( have_home, "browseable", "No"); 00733 commit_parameters(have_home); 00734 } 00735 00736 /* Need to Delete Homes share? */ 00737 if ((HomeExpo == 0) && (have_home != -1)) { 00738 lp_remove_service(have_home); 00739 have_home = -1; 00740 } 00741 00742 commit_parameters(GLOBAL_SECTION_SNUM); 00743 save_reload(0); 00744 } 00745 else 00746 { 00747 /* Now determine smb.conf WINS settings */ 00748 if (lp_wins_support()) 00749 winstype = 1; 00750 if (lp_wins_server_list() && strlen(*lp_wins_server_list())) 00751 winstype = 2; 00752 00753 00754 /* Do we have a homes share? */ 00755 have_home = lp_servicenumber(HOMES_NAME); 00756 } 00757 if ((winstype == 2) && lp_wins_support()) 00758 winstype = 3; 00759 00760 role = lp_server_role(); 00761 00762 /* Here we go ... */ 00763 printf("<H2>%s</H2>\n", _("Samba Configuration Wizard")); 00764 printf("<form method=post action=wizard>\n"); 00765 00766 if (have_write_access) { 00767 printf("%s\n", _("The \"Rewrite smb.conf file\" button will clear the smb.conf file of all default values and of comments.")); 00768 printf("%s", _("The same will happen if you press the commit button.")); 00769 printf("<br><br>\n"); 00770 printf("<center>"); 00771 printf("<input type=submit name=\"Rewrite\" value=\"%s\"> ",_("Rewrite smb.conf file")); 00772 printf("<input type=submit name=\"Commit\" value=\"%s\"> ",_("Commit")); 00773 printf("<input type=submit name=\"GetWizardParams\" value=\"%s\">", _("Edit Parameter Values")); 00774 printf("</center>\n"); 00775 } 00776 00777 printf("<hr>"); 00778 printf("<center><table border=0>"); 00779 printf("<tr><td><b>%s: </b></td>\n", _("Server Type")); 00780 printf("<td><input type=radio name=\"ServerType\" value=\"0\" %s> %s </td>", ((role == ROLE_STANDALONE) ? "checked" : ""), _("Stand Alone")); 00781 printf("<td><input type=radio name=\"ServerType\" value=\"1\" %s> %s </td>", ((role == ROLE_DOMAIN_MEMBER) ? "checked" : ""), _("Domain Member")); 00782 printf("<td><input type=radio name=\"ServerType\" value=\"2\" %s> %s </td>", ((role == ROLE_DOMAIN_PDC) ? "checked" : ""), _("Domain Controller")); 00783 printf("</tr>\n"); 00784 if (role == ROLE_DOMAIN_BDC) { 00785 printf("<tr><td></td><td colspan=3><font color=\"#ff0000\">%s</font></td></tr>\n", _("Unusual Type in smb.conf - Please Select New Mode")); 00786 } 00787 printf("<tr><td><b>%s: </b></td>\n", _("Configure WINS As")); 00788 printf("<td><input type=radio name=\"WINSType\" value=\"0\" %s> %s </td>", ((winstype == 0) ? "checked" : ""), _("Not Used")); 00789 printf("<td><input type=radio name=\"WINSType\" value=\"1\" %s> %s </td>", ((winstype == 1) ? "checked" : ""), _("Server for client use")); 00790 printf("<td><input type=radio name=\"WINSType\" value=\"2\" %s> %s </td>", ((winstype == 2) ? "checked" : ""), _("Client of another WINS server")); 00791 printf("</tr>\n"); 00792 printf("<tr><td></td><td></td><td></td><td>%s <input type=text size=\"16\" name=\"WINSAddr\" value=\"", _("Remote WINS Server")); 00793 00794 /* Print out the list of wins servers */ 00795 if(lp_wins_server_list()) { 00796 int i; 00797 const char **wins_servers = lp_wins_server_list(); 00798 for(i = 0; wins_servers[i]; i++) printf("%s ", wins_servers[i]); 00799 } 00800 00801 printf("\"></td></tr>\n"); 00802 if (winstype == 3) { 00803 printf("<tr><td></td><td colspan=3><font color=\"#ff0000\">%s</font></td></tr>\n", _("Error: WINS Server Mode and WINS Support both set in smb.conf")); 00804 printf("<tr><td></td><td colspan=3><font color=\"#ff0000\">%s</font></td></tr>\n", _("Please Select desired WINS mode above.")); 00805 } 00806 printf("<tr><td><b>%s: </b></td>\n", _("Expose Home Directories")); 00807 printf("<td><input type=radio name=\"HomeExpo\" value=\"1\" %s> Yes</td>", (have_home == -1) ? "" : "checked "); 00808 printf("<td><input type=radio name=\"HomeExpo\" value=\"0\" %s> No</td>", (have_home == -1 ) ? "checked" : ""); 00809 printf("<td></td></tr>\n"); 00810 00811 /* Enable this when we are ready .... 00812 * printf("<tr><td><b>%s: </b></td>\n", _("Is Print Server")); 00813 * printf("<td><input type=radio name=\"PtrSvr\" value=\"1\" %s> Yes</td>"); 00814 * printf("<td><input type=radio name=\"PtrSvr\" value=\"0\" %s> No</td>"); 00815 * printf("<td></td></tr>\n"); 00816 */ 00817 00818 printf("</table></center>"); 00819 printf("<hr>"); 00820 00821 printf("%s\n", _("The above configuration options will set multiple parameters and will generally assist with rapid Samba deployment.")); 00822 printf("</form>\n"); 00823 }
static void globals_page | ( | void | ) | [static] |
参照先 cgi_variable()・cgi_variable_nonull()・commit_parameters()・have_write_access・mode・printf()・save_reload()・show_parameters()・ViewModeBoxes().
参照元 main().
00830 { 00831 unsigned int parm_filter = FLAG_BASIC; 00832 int mode = 0; 00833 00834 printf("<H2>%s</H2>\n", _("Global Parameters")); 00835 00836 if (cgi_variable("Commit")) { 00837 commit_parameters(GLOBAL_SECTION_SNUM); 00838 save_reload(0); 00839 } 00840 00841 if ( cgi_variable("ViewMode") ) 00842 mode = atoi(cgi_variable_nonull("ViewMode")); 00843 if ( cgi_variable("BasicMode")) 00844 mode = 0; 00845 if ( cgi_variable("AdvMode")) 00846 mode = 1; 00847 00848 printf("<form name=\"swatform\" method=post action=globals>\n"); 00849 00850 ViewModeBoxes( mode ); 00851 switch ( mode ) { 00852 case 0: 00853 parm_filter = FLAG_BASIC; 00854 break; 00855 case 1: 00856 parm_filter = FLAG_ADVANCED; 00857 break; 00858 } 00859 printf("<br>\n"); 00860 if (have_write_access) { 00861 printf("<input type=submit name=\"Commit\" value=\"%s\">\n", 00862 _("Commit Changes")); 00863 } 00864 00865 printf("<input type=reset name=\"Reset Values\" value=\"%s\">\n", 00866 _("Reset Values")); 00867 00868 printf("<p>\n"); 00869 printf("<table>\n"); 00870 show_parameters(GLOBAL_SECTION_SNUM, 1, parm_filter, 0); 00871 printf("</table>\n"); 00872 printf("</form>\n"); 00873 }
static void shares_page | ( | void | ) | [static] |
参照先 cgi_variable()・cgi_variable_nonull()・commit_parameters()・have_write_access・iNumNonAutoPrintServices・load_config()・mode・printf()・push_utf8_allocate()・save_reload()・share・show_parameters()・ViewModeBoxes().
参照元 main().
00879 { 00880 const char *share = cgi_variable("share"); 00881 char *s; 00882 char *utf8_s; 00883 int snum = -1; 00884 int i; 00885 int mode = 0; 00886 unsigned int parm_filter = FLAG_BASIC; 00887 00888 if (share) 00889 snum = lp_servicenumber(share); 00890 00891 printf("<H2>%s</H2>\n", _("Share Parameters")); 00892 00893 if (cgi_variable("Commit") && snum >= 0) { 00894 commit_parameters(snum); 00895 save_reload(0); 00896 } 00897 00898 if (cgi_variable("Delete") && snum >= 0) { 00899 lp_remove_service(snum); 00900 save_reload(0); 00901 share = NULL; 00902 snum = -1; 00903 } 00904 00905 if (cgi_variable("createshare") && (share=cgi_variable("newshare"))) { 00906 load_config(False); 00907 lp_copy_service(GLOBAL_SECTION_SNUM, share); 00908 iNumNonAutoPrintServices = lp_numservices(); 00909 save_reload(0); 00910 snum = lp_servicenumber(share); 00911 } 00912 00913 printf("<FORM name=\"swatform\" method=post>\n"); 00914 00915 printf("<table>\n"); 00916 00917 if ( cgi_variable("ViewMode") ) 00918 mode = atoi(cgi_variable_nonull("ViewMode")); 00919 if ( cgi_variable("BasicMode")) 00920 mode = 0; 00921 if ( cgi_variable("AdvMode")) 00922 mode = 1; 00923 00924 ViewModeBoxes( mode ); 00925 switch ( mode ) { 00926 case 0: 00927 parm_filter = FLAG_BASIC; 00928 break; 00929 case 1: 00930 parm_filter = FLAG_ADVANCED; 00931 break; 00932 } 00933 printf("<br><tr>\n"); 00934 printf("<td><input type=submit name=selectshare value=\"%s\"></td>\n", _("Choose Share")); 00935 printf("<td><select name=share>\n"); 00936 if (snum < 0) 00937 printf("<option value=\" \"> \n"); 00938 for (i=0;i<lp_numservices();i++) { 00939 s = lp_servicename(i); 00940 if (s && (*s) && strcmp(s,"IPC$") && !lp_print_ok(i)) { 00941 push_utf8_allocate(&utf8_s, s); 00942 printf("<option %s value=\"%s\">%s\n", 00943 (share && strcmp(share,s)==0)?"SELECTED":"", 00944 utf8_s, utf8_s); 00945 SAFE_FREE(utf8_s); 00946 00947 } 00948 } 00949 printf("</select></td>\n"); 00950 if (have_write_access) { 00951 printf("<td><input type=submit name=\"Delete\" value=\"%s\"></td>\n", _("Delete Share")); 00952 } 00953 printf("</tr>\n"); 00954 printf("</table>"); 00955 printf("<table>"); 00956 if (have_write_access) { 00957 printf("<tr>\n"); 00958 printf("<td><input type=submit name=createshare value=\"%s\"></td>\n", _("Create Share")); 00959 printf("<td><input type=text size=30 name=newshare></td></tr>\n"); 00960 } 00961 printf("</table>"); 00962 00963 00964 if (snum >= 0) { 00965 if (have_write_access) { 00966 printf("<input type=submit name=\"Commit\" value=\"%s\">\n", _("Commit Changes")); 00967 } 00968 00969 printf("<input type=reset name=\"Reset Values\" value=\"%s\">\n", _("Reset Values")); 00970 printf("<p>\n"); 00971 } 00972 00973 if (snum >= 0) { 00974 printf("<table>\n"); 00975 show_parameters(snum, 1, parm_filter, 0); 00976 printf("</table>\n"); 00977 } 00978 00979 printf("</FORM>\n"); 00980 }
static BOOL change_password | ( | const char * | remote_machine, | |
const char * | user_name, | |||
const char * | old_passwd, | |||
const char * | new_passwd, | |||
int | local_flags | |||
) | [static] |
参照先 demo_mode・initialize_password_db()・local_password_change()・printf()・remote_password_change().
参照元 chg_passwd().
00988 { 00989 NTSTATUS ret; 00990 pstring err_str; 00991 pstring msg_str; 00992 00993 if (demo_mode) { 00994 printf("%s\n<p>", _("password change in demo mode rejected")); 00995 return False; 00996 } 00997 00998 if (remote_machine != NULL) { 00999 ret = remote_password_change(remote_machine, user_name, old_passwd, 01000 new_passwd, err_str, sizeof(err_str)); 01001 if(*err_str) 01002 printf("%s\n<p>", err_str); 01003 return NT_STATUS_IS_OK(ret); 01004 } 01005 01006 if(!initialize_password_db(True)) { 01007 printf("%s\n<p>", _("Can't setup password database vectors.")); 01008 return False; 01009 } 01010 01011 ret = local_password_change(user_name, local_flags, new_passwd, err_str, sizeof(err_str), 01012 msg_str, sizeof(msg_str)); 01013 01014 if(*msg_str) 01015 printf("%s\n<p>", msg_str); 01016 if(*err_str) 01017 printf("%s\n<p>", err_str); 01018 01019 return NT_STATUS_IS_OK(ret); 01020 }
static void chg_passwd | ( | void | ) | [static] |
参照先 am_root()・cgi_variable()・cgi_variable_nonull()・change_password()・host・printf().
参照元 passwd_page().
01026 { 01027 const char *host; 01028 BOOL rslt; 01029 int local_flags = 0; 01030 01031 /* Make sure users name has been specified */ 01032 if (strlen(cgi_variable_nonull(SWAT_USER)) == 0) { 01033 printf("<p>%s\n", _(" Must specify \"User Name\" ")); 01034 return; 01035 } 01036 01037 /* 01038 * smbpasswd doesn't require anything but the users name to delete, disable or enable the user, 01039 * so if that's what we're doing, skip the rest of the checks 01040 */ 01041 if (!cgi_variable(DISABLE_USER_FLAG) && !cgi_variable(ENABLE_USER_FLAG) && !cgi_variable(DELETE_USER_FLAG)) { 01042 01043 /* 01044 * If current user is not root, make sure old password has been specified 01045 * If REMOTE change, even root must provide old password 01046 */ 01047 if (((!am_root()) && (strlen( cgi_variable_nonull(OLD_PSWD)) <= 0)) || 01048 ((cgi_variable(CHG_R_PASSWD_FLAG)) && (strlen( cgi_variable_nonull(OLD_PSWD)) <= 0))) { 01049 printf("<p>%s\n", _(" Must specify \"Old Password\" ")); 01050 return; 01051 } 01052 01053 /* If changing a users password on a remote hosts we have to know what host */ 01054 if ((cgi_variable(CHG_R_PASSWD_FLAG)) && (strlen( cgi_variable_nonull(RHOST)) <= 0)) { 01055 printf("<p>%s\n", _(" Must specify \"Remote Machine\" ")); 01056 return; 01057 } 01058 01059 /* Make sure new passwords have been specified */ 01060 if ((strlen( cgi_variable_nonull(NEW_PSWD)) <= 0) || 01061 (strlen( cgi_variable_nonull(NEW2_PSWD)) <= 0)) { 01062 printf("<p>%s\n", _(" Must specify \"New, and Re-typed Passwords\" ")); 01063 return; 01064 } 01065 01066 /* Make sure new passwords was typed correctly twice */ 01067 if (strcmp(cgi_variable_nonull(NEW_PSWD), cgi_variable_nonull(NEW2_PSWD)) != 0) { 01068 printf("<p>%s\n", _(" Re-typed password didn't match new password ")); 01069 return; 01070 } 01071 } 01072 01073 if (cgi_variable(CHG_R_PASSWD_FLAG)) { 01074 host = cgi_variable(RHOST); 01075 } else if (am_root()) { 01076 host = NULL; 01077 } else { 01078 host = "127.0.0.1"; 01079 } 01080 01081 /* 01082 * Set up the local flags. 01083 */ 01084 01085 local_flags |= (cgi_variable(ADD_USER_FLAG) ? LOCAL_ADD_USER : 0); 01086 local_flags |= (cgi_variable(ADD_USER_FLAG) ? LOCAL_SET_PASSWORD : 0); 01087 local_flags |= (cgi_variable(CHG_S_PASSWD_FLAG) ? LOCAL_SET_PASSWORD : 0); 01088 local_flags |= (cgi_variable(DELETE_USER_FLAG) ? LOCAL_DELETE_USER : 0); 01089 local_flags |= (cgi_variable(ENABLE_USER_FLAG) ? LOCAL_ENABLE_USER : 0); 01090 local_flags |= (cgi_variable(DISABLE_USER_FLAG) ? LOCAL_DISABLE_USER : 0); 01091 01092 01093 rslt = change_password(host, 01094 cgi_variable_nonull(SWAT_USER), 01095 cgi_variable_nonull(OLD_PSWD), cgi_variable_nonull(NEW_PSWD), 01096 local_flags); 01097 01098 if(cgi_variable(CHG_S_PASSWD_FLAG)) { 01099 printf("<p>"); 01100 if (rslt == True) { 01101 printf(_(" The passwd for '%s' has been changed."), cgi_variable_nonull(SWAT_USER)); 01102 printf("\n"); 01103 } else { 01104 printf(_(" The passwd for '%s' has NOT been changed."), cgi_variable_nonull(SWAT_USER)); 01105 printf("\n"); 01106 } 01107 } 01108 01109 return; 01110 }
static void passwd_page | ( | void | ) | [static] |
参照先 am_root()・cgi_user_name()・cgi_variable()・cgi_variable_nonull()・chg_passwd()・demo_mode・printf().
参照元 main().
01116 { 01117 const char *new_name = cgi_user_name(); 01118 01119 /* 01120 * After the first time through here be nice. If the user 01121 * changed the User box text to another users name, remember it. 01122 */ 01123 if (cgi_variable(SWAT_USER)) { 01124 new_name = cgi_variable_nonull(SWAT_USER); 01125 } 01126 01127 if (!new_name) new_name = ""; 01128 01129 printf("<H2>%s</H2>\n", _("Server Password Management")); 01130 01131 printf("<FORM name=\"swatform\" method=post>\n"); 01132 01133 printf("<table>\n"); 01134 01135 /* 01136 * Create all the dialog boxes for data collection 01137 */ 01138 printf("<tr><td> %s : </td>\n", _("User Name")); 01139 printf("<td><input type=text size=30 name=%s value=%s></td></tr> \n", SWAT_USER, new_name); 01140 if (!am_root()) { 01141 printf("<tr><td> %s : </td>\n", _("Old Password")); 01142 printf("<td><input type=password size=30 name=%s></td></tr> \n",OLD_PSWD); 01143 } 01144 printf("<tr><td> %s : </td>\n", _("New Password")); 01145 printf("<td><input type=password size=30 name=%s></td></tr>\n",NEW_PSWD); 01146 printf("<tr><td> %s : </td>\n", _("Re-type New Password")); 01147 printf("<td><input type=password size=30 name=%s></td></tr>\n",NEW2_PSWD); 01148 printf("</table>\n"); 01149 01150 /* 01151 * Create all the control buttons for requesting action 01152 */ 01153 printf("<input type=submit name=%s value=\"%s\">\n", 01154 CHG_S_PASSWD_FLAG, _("Change Password")); 01155 if (demo_mode || am_root()) { 01156 printf("<input type=submit name=%s value=\"%s\">\n", 01157 ADD_USER_FLAG, _("Add New User")); 01158 printf("<input type=submit name=%s value=\"%s\">\n", 01159 DELETE_USER_FLAG, _("Delete User")); 01160 printf("<input type=submit name=%s value=\"%s\">\n", 01161 DISABLE_USER_FLAG, _("Disable User")); 01162 printf("<input type=submit name=%s value=\"%s\">\n", 01163 ENABLE_USER_FLAG, _("Enable User")); 01164 } 01165 printf("<p></FORM>\n"); 01166 01167 /* 01168 * Do some work if change, add, disable or enable was 01169 * requested. It could be this is the first time through this 01170 * code, so there isn't anything to do. */ 01171 if ((cgi_variable(CHG_S_PASSWD_FLAG)) || (cgi_variable(ADD_USER_FLAG)) || (cgi_variable(DELETE_USER_FLAG)) || 01172 (cgi_variable(DISABLE_USER_FLAG)) || (cgi_variable(ENABLE_USER_FLAG))) { 01173 chg_passwd(); 01174 } 01175 01176 printf("<H2>%s</H2>\n", _("Client/Server Password Management")); 01177 01178 printf("<FORM name=\"swatform\" method=post>\n"); 01179 01180 printf("<table>\n"); 01181 01182 /* 01183 * Create all the dialog boxes for data collection 01184 */ 01185 printf("<tr><td> %s : </td>\n", _("User Name")); 01186 printf("<td><input type=text size=30 name=%s value=%s></td></tr>\n",SWAT_USER, new_name); 01187 printf("<tr><td> %s : </td>\n", _("Old Password")); 01188 printf("<td><input type=password size=30 name=%s></td></tr>\n",OLD_PSWD); 01189 printf("<tr><td> %s : </td>\n", _("New Password")); 01190 printf("<td><input type=password size=30 name=%s></td></tr>\n",NEW_PSWD); 01191 printf("<tr><td> %s : </td>\n", _("Re-type New Password")); 01192 printf("<td><input type=password size=30 name=%s></td></tr>\n",NEW2_PSWD); 01193 printf("<tr><td> %s : </td>\n", _("Remote Machine")); 01194 printf("<td><input type=text size=30 name=%s></td></tr>\n",RHOST); 01195 01196 printf("</table>"); 01197 01198 /* 01199 * Create all the control buttons for requesting action 01200 */ 01201 printf("<input type=submit name=%s value=\"%s\">", 01202 CHG_R_PASSWD_FLAG, _("Change Password")); 01203 01204 printf("<p></FORM>\n"); 01205 01206 /* 01207 * Do some work if a request has been made to change the 01208 * password somewhere other than the server. It could be this 01209 * is the first time through this code, so there isn't 01210 * anything to do. */ 01211 if (cgi_variable(CHG_R_PASSWD_FLAG)) { 01212 chg_passwd(); 01213 } 01214 01215 }
static void printers_page | ( | void | ) | [static] |
参照先 cgi_variable()・cgi_variable_nonull()・commit_parameters()・have_write_access・iNumNonAutoPrintServices・load_config()・lp_do_parameter()・mode・printf()・save_reload()・share・show_parameters()・ViewModeBoxes().
参照元 main().
01221 { 01222 const char *share = cgi_variable("share"); 01223 char *s; 01224 int snum=-1; 01225 int i; 01226 int mode = 0; 01227 unsigned int parm_filter = FLAG_BASIC; 01228 01229 if (share) 01230 snum = lp_servicenumber(share); 01231 01232 printf("<H2>%s</H2>\n", _("Printer Parameters")); 01233 01234 printf("<H3>%s</H3>\n", _("Important Note:")); 01235 printf(_("Printer names marked with [*] in the Choose Printer drop-down box ")); 01236 printf(_("are autoloaded printers from ")); 01237 printf("<A HREF=\"/swat/help/smb.conf.5.html#printcapname\" target=\"docs\">%s</A>\n", _("Printcap Name")); 01238 printf("%s\n", _("Attempting to delete these printers from SWAT will have no effect.")); 01239 01240 if (cgi_variable("Commit") && snum >= 0) { 01241 commit_parameters(snum); 01242 if (snum >= iNumNonAutoPrintServices) 01243 save_reload(snum); 01244 else 01245 save_reload(0); 01246 } 01247 01248 if (cgi_variable("Delete") && snum >= 0) { 01249 lp_remove_service(snum); 01250 save_reload(0); 01251 share = NULL; 01252 snum = -1; 01253 } 01254 01255 if (cgi_variable("createshare") && (share=cgi_variable("newshare"))) { 01256 load_config(False); 01257 lp_copy_service(GLOBAL_SECTION_SNUM, share); 01258 iNumNonAutoPrintServices = lp_numservices(); 01259 snum = lp_servicenumber(share); 01260 lp_do_parameter(snum, "print ok", "Yes"); 01261 save_reload(0); 01262 snum = lp_servicenumber(share); 01263 } 01264 01265 printf("<FORM name=\"swatform\" method=post>\n"); 01266 01267 if ( cgi_variable("ViewMode") ) 01268 mode = atoi(cgi_variable_nonull("ViewMode")); 01269 if ( cgi_variable("BasicMode")) 01270 mode = 0; 01271 if ( cgi_variable("AdvMode")) 01272 mode = 1; 01273 01274 ViewModeBoxes( mode ); 01275 switch ( mode ) { 01276 case 0: 01277 parm_filter = FLAG_BASIC; 01278 break; 01279 case 1: 01280 parm_filter = FLAG_ADVANCED; 01281 break; 01282 } 01283 printf("<table>\n"); 01284 printf("<tr><td><input type=submit name=\"selectshare\" value=\"%s\"></td>\n", _("Choose Printer")); 01285 printf("<td><select name=\"share\">\n"); 01286 if (snum < 0 || !lp_print_ok(snum)) 01287 printf("<option value=\" \"> \n"); 01288 for (i=0;i<lp_numservices();i++) { 01289 s = lp_servicename(i); 01290 if (s && (*s) && strcmp(s,"IPC$") && lp_print_ok(i)) { 01291 if (i >= iNumNonAutoPrintServices) 01292 printf("<option %s value=\"%s\">[*]%s\n", 01293 (share && strcmp(share,s)==0)?"SELECTED":"", 01294 s, s); 01295 else 01296 printf("<option %s value=\"%s\">%s\n", 01297 (share && strcmp(share,s)==0)?"SELECTED":"", 01298 s, s); 01299 } 01300 } 01301 printf("</select></td>"); 01302 if (have_write_access) { 01303 printf("<td><input type=submit name=\"Delete\" value=\"%s\"></td>\n", _("Delete Printer")); 01304 } 01305 printf("</tr>"); 01306 printf("</table>\n"); 01307 01308 if (have_write_access) { 01309 printf("<table>\n"); 01310 printf("<tr><td><input type=submit name=\"createshare\" value=\"%s\"></td>\n", _("Create Printer")); 01311 printf("<td><input type=text size=30 name=\"newshare\"></td></tr>\n"); 01312 printf("</table>"); 01313 } 01314 01315 01316 if (snum >= 0) { 01317 if (have_write_access) { 01318 printf("<input type=submit name=\"Commit\" value=\"%s\">\n", _("Commit Changes")); 01319 } 01320 printf("<input type=reset name=\"Reset Values\" value=\"%s\">\n", _("Reset Values")); 01321 printf("<p>\n"); 01322 } 01323 01324 if (snum >= 0) { 01325 printf("<table>\n"); 01326 show_parameters(snum, 1, parm_filter, 1); 01327 printf("</table>\n"); 01328 } 01329 printf("</FORM>\n"); 01330 }
int main | ( | int | argc, | |
char * | argv[] | |||
) |
main function for SWAT.
参照先 BlockSignals()・cgi_load_variables()・cgi_pathinfo()・cgi_setup()・dbf・demo_mode・dyn_CONFIGFILE・dyn_SWATDIR・fault_setup()・file_exist()・globals_page()・have_read_access・have_write_access・iNumNonAutoPrintServices・load_case_tables()・load_config()・load_interfaces()・load_printers()・passwd_only・passwd_page()・poptFreeContext()・poptGetContext()・poptGetNextOpt()・print_footer()・print_header()・printers_page()・rewritecfg_file()・setup_logging()・shares_page()・show_main_buttons()・status_page()・viewconfig_page()・welcome_page()・wizard_page()・wizard_params_page()・x_fopen()・x_stderr.
01337 { 01338 const char *page; 01339 poptContext pc; 01340 struct poptOption long_options[] = { 01341 POPT_AUTOHELP 01342 { "disable-authentication", 'a', POPT_ARG_VAL, &demo_mode, True, "Disable authentication (demo mode)" }, 01343 { "password-menu-only", 'P', POPT_ARG_VAL, &passwd_only, True, "Show only change password menu" }, 01344 POPT_COMMON_SAMBA 01345 POPT_TABLEEND 01346 }; 01347 01348 fault_setup(NULL); 01349 umask(S_IWGRP | S_IWOTH); 01350 01351 #if defined(HAVE_SET_AUTH_PARAMETERS) 01352 set_auth_parameters(argc, argv); 01353 #endif /* HAVE_SET_AUTH_PARAMETERS */ 01354 01355 /* just in case it goes wild ... */ 01356 alarm(300); 01357 01358 setlinebuf(stdout); 01359 01360 /* we don't want any SIGPIPE messages */ 01361 BlockSignals(True,SIGPIPE); 01362 01363 dbf = x_fopen("/dev/null", O_WRONLY, 0); 01364 if (!dbf) dbf = x_stderr; 01365 01366 /* we don't want stderr screwing us up */ 01367 close(2); 01368 open("/dev/null", O_WRONLY); 01369 01370 pc = poptGetContext("swat", argc, (const char **) argv, long_options, 0); 01371 01372 /* Parse command line options */ 01373 01374 while(poptGetNextOpt(pc) != -1) { } 01375 01376 poptFreeContext(pc); 01377 01378 load_case_tables(); 01379 01380 setup_logging(argv[0],False); 01381 load_config(True); 01382 load_interfaces(); 01383 iNumNonAutoPrintServices = lp_numservices(); 01384 load_printers(); 01385 01386 cgi_setup(dyn_SWATDIR, !demo_mode); 01387 01388 print_header(); 01389 01390 cgi_load_variables(); 01391 01392 if (!file_exist(dyn_CONFIGFILE, NULL)) { 01393 have_read_access = True; 01394 have_write_access = True; 01395 } else { 01396 /* check if the authenticated user has write access - if not then 01397 don't show write options */ 01398 have_write_access = (access(dyn_CONFIGFILE,W_OK) == 0); 01399 01400 /* if the user doesn't have read access to smb.conf then 01401 don't let them view it */ 01402 have_read_access = (access(dyn_CONFIGFILE,R_OK) == 0); 01403 } 01404 01405 show_main_buttons(); 01406 01407 page = cgi_pathinfo(); 01408 01409 /* Root gets full functionality */ 01410 if (have_read_access && strcmp(page, "globals")==0) { 01411 globals_page(); 01412 } else if (have_read_access && strcmp(page,"shares")==0) { 01413 shares_page(); 01414 } else if (have_read_access && strcmp(page,"printers")==0) { 01415 printers_page(); 01416 } else if (have_read_access && strcmp(page,"status")==0) { 01417 status_page(); 01418 } else if (have_read_access && strcmp(page,"viewconfig")==0) { 01419 viewconfig_page(); 01420 } else if (strcmp(page,"passwd")==0) { 01421 passwd_page(); 01422 } else if (have_read_access && strcmp(page,"wizard")==0) { 01423 wizard_page(); 01424 } else if (have_read_access && strcmp(page,"wizard_params")==0) { 01425 wizard_params_page(); 01426 } else if (have_read_access && strcmp(page,"rewritecfg")==0) { 01427 rewritecfg_file(); 01428 } else { 01429 welcome_page(); 01430 } 01431 01432 print_footer(); 01433 return 0; 01434 }
BOOL passwd_only = False [static] |
BOOL have_write_access = False [static] |
BOOL have_read_access = False [static] |
int iNumNonAutoPrintServices = 0 [static] |