/*
some simple CGI helper routines
Copyright (C) Andrew Tridgell 1997-1998
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
while ((*cl)) {
int c;
-
+
if (i == len) {
char *ret2;
if (len == 0) len = 1024;
if (!ret2) return ret;
ret = ret2;
}
-
+
c = fgetc(f);
(*cl)--;
(*cl) = 0;
break;
}
-
+
if (c == '\r') continue;
if (strchr_m("\n&", c)) break;
ret[i++] = c;
}
-
+
if (ret) {
ret[i] = 0;
}
while (len && (line=grab_line(f, &len))) {
p = strchr_m(line,'=');
if (!p) continue;
-
+
*p = 0;
-
+
variables[num_variables].name = SMB_STRDUP(line);
variables[num_variables].value = SMB_STRDUP(p+1);
SAFE_FREE(line);
-
+
if (!variables[num_variables].name ||
!variables[num_variables].value)
continue;
variables[num_variables].name,
variables[num_variables].value);
#endif
-
+
num_variables++;
if (num_variables == MAX_VARIABLES) break;
}
tok=strtok_r(NULL, "&;", &saveptr)) {
p = strchr_m(tok,'=');
if (!p) continue;
-
+
*p = 0;
-
+
variables[num_variables].name = SMB_STRDUP(tok);
variables[num_variables].value = SMB_STRDUP(p+1);
/*
* Try and get the user from the UNIX password file.
*/
-
+
pass = getpwnam_alloc(talloc_autofree_context(), user);
-
+
/*
* Validate the password they have given.
*/
-
+
if NT_STATUS_IS_OK(pass_check(pass, user, user_pass,
strlen(user_pass), NULL, False)) {
-
+
if (pass) {
/*
* Password was ok.
*/
-
+
if ( initgroups(pass->pw_name, pass->pw_gid) != 0 )
goto err;
become_user_permanently(pass->pw_uid, pass->pw_gid);
-
+
/* Save the users name */
C_user = SMB_STRDUP(user);
TALLOC_FREE(pass);
return True;
}
}
-
+
err:
cgi_setup_error("401 Bad Authorization",
"WWW-Authenticate: Basic realm=\"SWAT\"\r\n",
Version 3.0.0
Copyright (C) Andrew Tridgell 1997-2002
Copyright (C) John H Terpstra 2002
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
}
if ((parm_filter & FLAG_WIZARD) && !(parm->flags & FLAG_WIZARD)) continue;
-
+
if ((parm_filter & FLAG_ADVANCED) && !(parm->flags & FLAG_ADVANCED)) continue;
-
+
if (heading && heading != last_heading) {
printf("<tr><td></td></tr><tr><td><b><u>%s</u></b></td></tr>\n", _(heading));
last_heading = heading;
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", current_timestring(ctx, False));
-
+
lp_dump(f, show_defaults, iNumNonAutoPrintServices);
TALLOC_FREE(ctx);
static void show_main_buttons(void)
{
char *p;
-
+
if ((p = cgi_user_name()) && strcmp(p, "root")) {
printf(_("Logged in as <b>%s</b>"), p);
printf("<p>\n");
printf("<input type=reset name=\"Reset Values\" value=\"Reset\">\n");
printf("<p>\n");
-
+
printf("<table>\n");
show_parameters(GLOBAL_SECTION_SNUM, 1, parm_filter, 0);
printf("</table>\n");
/* Plain text passwords are too badly broken - use encrypted passwords only */
lp_do_parameter( GLOBAL_SECTION_SNUM, "encrypt passwords", "Yes");
-
+
switch ( SerType ){
case 0:
/* Stand-alone Server */
winstype = 3;
role = lp_server_role();
-
+
/* Here we go ... */
printf("<H2>%s</H2>\n", _("Samba Configuration Wizard"));
printf("<form method=post action=wizard>\n");
const char **wins_servers = lp_wins_server_list();
for(i = 0; wins_servers[i]; i++) printf("%s ", wins_servers[i]);
}
-
+
printf("\"></td></tr>\n");
if (winstype == 3) {
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"));
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>\n");
-
+
/* Enable this when we are ready ....
* 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>\n");
*/
-
+
printf("</table></center>");
printf("<hr>");
printf("%s\n<p>", _("password change in demo mode rejected"));
return False;
}
-
+
if (remote_machine != NULL) {
ret = remote_password_change(remote_machine, user_name,
old_passwd, new_passwd, &err_str);
printf("%s\n<p>", _("Can't setup password database vectors."));
return False;
}
-
+
ret = local_password_change(user_name, local_flags, new_passwd,
&err_str, &msg_str);
local_flags |= (cgi_variable(DELETE_USER_FLAG) ? LOCAL_DELETE_USER : 0);
local_flags |= (cgi_variable(ENABLE_USER_FLAG) ? LOCAL_ENABLE_USER : 0);
local_flags |= (cgi_variable(DISABLE_USER_FLAG) ? LOCAL_DISABLE_USER : 0);
-
rslt = change_password(host,
cgi_variable_nonull(SWAT_USER),
printf("\n");
}
}
-
+
return;
}