mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-10 18:23:28 +00:00
Implemented 'allow password change', added new redirection code without using 'URL =' statement
SVN revision: 1643
This commit is contained in:
parent
9c1bdf0718
commit
e75b19f5fb
@ -1555,6 +1555,16 @@ notification to the admin user(s). The option <b>3</b> is used to <i>only</i> se
|
|||||||
email notification to tha admin users(s), which then can validate the account and commit
|
email notification to tha admin users(s), which then can validate the account and commit
|
||||||
it by hitting the URL given in the email notification.<p>
|
it by hitting the URL given in the email notification.<p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<LI><b><code>Allow password change = 0|1</code></b>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
Enables or disabled the ability for users to change their password. If disabled,
|
||||||
|
the <i>"Forgot password?</i> link in the login page is ommitted as well.
|
||||||
|
The admin user(s) can always change passwords.
|
||||||
|
<p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<LI><b><code>Allow <command> = <user list></code></b>
|
<LI><b><code>Allow <command> = <user list></code></b>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
200
src/elogd.c
200
src/elogd.c
@ -3618,7 +3618,7 @@ int el_build_index(LOGBOOK * lbs, BOOL rebuild)
|
|||||||
strlcpy(file_name, dir, sizeof(file_name));
|
strlcpy(file_name, dir, sizeof(file_name));
|
||||||
strlcat(file_name, file_list + index * MAX_PATH_LENGTH, sizeof(file_name));
|
strlcat(file_name, file_list + index * MAX_PATH_LENGTH, sizeof(file_name));
|
||||||
|
|
||||||
fh = open(file_name, O_RDWR | O_BINARY, 0644);
|
fh = open(file_name, O_RDONLY | O_BINARY, 0644);
|
||||||
|
|
||||||
if (fh < 0) {
|
if (fh < 0) {
|
||||||
sprintf(str, "Cannot open file \"%s\"", file_name);
|
sprintf(str, "Cannot open file \"%s\"", file_name);
|
||||||
@ -4052,7 +4052,7 @@ int el_retrieve(LOGBOOK * lbs,
|
|||||||
return EL_NO_MSG;
|
return EL_NO_MSG;
|
||||||
|
|
||||||
sprintf(file_name, "%s%s", lbs->data_dir, lbs->el_index[index].file_name);
|
sprintf(file_name, "%s%s", lbs->data_dir, lbs->el_index[index].file_name);
|
||||||
fh = open(file_name, O_RDWR | O_BINARY, 0644);
|
fh = open(file_name, O_RDONLY | O_BINARY, 0644);
|
||||||
if (fh < 0) {
|
if (fh < 0) {
|
||||||
/* file might have been deleted, rebuild index */
|
/* file might have been deleted, rebuild index */
|
||||||
el_build_index(lbs, TRUE);
|
el_build_index(lbs, TRUE);
|
||||||
@ -4274,7 +4274,7 @@ int el_retrieve_attachment(LOGBOOK * lbs, int message_id, int n, char name[MAX_P
|
|||||||
return EL_NO_MSG;
|
return EL_NO_MSG;
|
||||||
|
|
||||||
sprintf(file_name, "%s%s", lbs->data_dir, lbs->el_index[index].file_name);
|
sprintf(file_name, "%s%s", lbs->data_dir, lbs->el_index[index].file_name);
|
||||||
fh = open(file_name, O_RDWR | O_BINARY, 0644);
|
fh = open(file_name, O_RDONLY | O_BINARY, 0644);
|
||||||
if (fh < 0) {
|
if (fh < 0) {
|
||||||
/* file might have been deleted, rebuild index */
|
/* file might have been deleted, rebuild index */
|
||||||
el_build_index(lbs, TRUE);
|
el_build_index(lbs, TRUE);
|
||||||
@ -5076,8 +5076,16 @@ void write_logfile(LOGBOOK * lbs, const char *text)
|
|||||||
sprintf(buf + strlen(buf), "{%s} ", lbs->name);
|
sprintf(buf + strlen(buf), "{%s} ", lbs->name);
|
||||||
|
|
||||||
strlcat(buf, text, sizeof(buf) - 1);
|
strlcat(buf, text, sizeof(buf) - 1);
|
||||||
if (buf[strlen(buf) - 1] != '\n')
|
#ifdef OS_WINNT
|
||||||
|
if (strlen(buf) > 0 && buf[strlen(buf) - 1] != '\n')
|
||||||
|
strlcat(buf, "\r\n", sizeof(buf));
|
||||||
|
else if (strlen(buf) > 1 && buf[strlen(buf) - 2] != '\r')
|
||||||
|
strlcpy(buf+strlen(buf)-2, "\r\n", sizeof(buf)-(strlen(buf)-2));
|
||||||
|
|
||||||
|
#else
|
||||||
|
if (strlen(buf) > 1 && buf[strlen(buf) - 1] != '\n')
|
||||||
strlcat(buf, "\n", sizeof(buf));
|
strlcat(buf, "\n", sizeof(buf));
|
||||||
|
#endif
|
||||||
|
|
||||||
write(fh, buf, strlen(buf));
|
write(fh, buf, strlen(buf));
|
||||||
|
|
||||||
@ -6181,7 +6189,7 @@ void compose_base_url(LOGBOOK * lbs, char *base_url, int size)
|
|||||||
|
|
||||||
void set_location(LOGBOOK * lbs, char *rel_path)
|
void set_location(LOGBOOK * lbs, char *rel_path)
|
||||||
{
|
{
|
||||||
char str[NAME_LENGTH];
|
char str[NAME_LENGTH], *p;
|
||||||
|
|
||||||
/* if path contains http(s), go directly there */
|
/* if path contains http(s), go directly there */
|
||||||
if (strncmp(rel_path, "http://", 7) == 0) {
|
if (strncmp(rel_path, "http://", 7) == 0) {
|
||||||
@ -6192,105 +6200,121 @@ void set_location(LOGBOOK * lbs, char *rel_path)
|
|||||||
rsputs(rel_path);
|
rsputs(rel_path);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (getcfg(lbs->name, "redirection", str, sizeof(str)) && atoi(str) == 1) {
|
/* check for URL options */
|
||||||
|
str[0] = 0;
|
||||||
|
if (lbs)
|
||||||
|
getcfg(lbs->name, "URL", str, sizeof(str));
|
||||||
|
else
|
||||||
|
getcfg("global", "URL", str, sizeof(str));
|
||||||
|
|
||||||
/* use relative redirection */
|
if (str[0] == 0) {
|
||||||
if (lbs)
|
|
||||||
getcfg(lbs->name, "URL", str, sizeof(str));
|
|
||||||
else
|
|
||||||
getcfg("global", "URL", str, sizeof(str));
|
|
||||||
|
|
||||||
if (!str[0]) {
|
/* get redirection from referer and host */
|
||||||
|
|
||||||
|
if (referer[0]) {
|
||||||
|
strlcpy(str, referer, sizeof(str));
|
||||||
|
|
||||||
|
/* strip any parameter */
|
||||||
|
if (strchr(str, '?'))
|
||||||
|
*strchr(str, '?') = 0;
|
||||||
|
|
||||||
|
/* strip rightmost '/' */
|
||||||
|
if (strrchr(str, '/'))
|
||||||
|
*strrchr(str, '/') = 0;
|
||||||
|
|
||||||
|
/* extract last subdir */
|
||||||
|
p = str+strlen(str);
|
||||||
|
while (p > str && *p != '/')
|
||||||
|
p--;
|
||||||
|
if (*p == '/')
|
||||||
|
p++;
|
||||||
|
|
||||||
|
/* if last subdir equals logbook name, strip it */
|
||||||
|
if (lbs && stricmp(p, lbs->name_enc) == 0)
|
||||||
|
*p = 0;
|
||||||
|
|
||||||
|
/* if last subdir equals top group, strip it */
|
||||||
|
if (!lbs && getcfg_topgroup() && stricmp(p, getcfg_topgroup()) == 0)
|
||||||
|
*p = 0;
|
||||||
|
|
||||||
|
} else {
|
||||||
/* assemble absolute path from host name and port */
|
/* assemble absolute path from host name and port */
|
||||||
sprintf(str, "http://%s", host_name);
|
sprintf(str, "http://%s", host_name);
|
||||||
if (elog_tcp_port != 80)
|
if (elog_tcp_port != 80)
|
||||||
sprintf(str + strlen(str), ":%d", elog_tcp_port);
|
sprintf(str + strlen(str), ":%d", elog_tcp_port);
|
||||||
strcat(str, "/");
|
strlcat(str, "/", sizeof(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add trailing '/' if not present */
|
/* add trailing '/' if not present */
|
||||||
if (str[strlen(str) - 1] != '/')
|
if (str[strlen(str) - 1] != '/')
|
||||||
strcat(str, "/");
|
strlcat(str, "/", sizeof(str));
|
||||||
|
|
||||||
|
/* add top group if existing and not logbook */
|
||||||
|
if (!lbs && getcfg_topgroup()) {
|
||||||
|
strlcat(str, getcfg_topgroup(), sizeof(str));
|
||||||
|
strlcat(str, "/", sizeof(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strncmp(rel_path, "../", 3) == 0)
|
||||||
|
strlcat(str, rel_path + 3, sizeof(str));
|
||||||
|
else if (strcmp(rel_path, ".") == 0) {
|
||||||
|
if (lbs)
|
||||||
|
strlcat(str, lbs->name_enc, sizeof(str));
|
||||||
|
} else if (rel_path[0] == '/')
|
||||||
|
strlcat(str, rel_path + 1, sizeof(str));
|
||||||
|
else {
|
||||||
|
if (lbs) {
|
||||||
|
strlcat(str, lbs->name_enc, sizeof(str));
|
||||||
|
strlcat(str, "/", sizeof(str));
|
||||||
|
strlcat(str, rel_path, sizeof(str));
|
||||||
|
} else
|
||||||
|
strlcat(str, rel_path, sizeof(str));
|
||||||
|
}
|
||||||
|
|
||||||
rsputs("Location: ");
|
rsputs("Location: ");
|
||||||
rsputs(str);
|
rsputs(str);
|
||||||
|
|
||||||
/* add top group if existing and not logbook */
|
|
||||||
if (!lbs && getcfg_topgroup()) {
|
|
||||||
rsputs(getcfg_topgroup());
|
|
||||||
rsputs("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strncmp(rel_path, "../", 3) == 0)
|
|
||||||
rsputs(rel_path + 3);
|
|
||||||
else if (strcmp(rel_path, ".") == 0) {
|
|
||||||
if (lbs)
|
|
||||||
rsputs(lbs->name_enc);
|
|
||||||
} else if (rel_path[0] == '/')
|
|
||||||
rsputs(rel_path + 1);
|
|
||||||
else {
|
|
||||||
if (lbs) {
|
|
||||||
rsputs(lbs->name_enc);
|
|
||||||
rsputs("/");
|
|
||||||
rsputs(rel_path);
|
|
||||||
} else
|
|
||||||
rsputs(rel_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* use absolute redirection */
|
/* use redirection via URL */
|
||||||
|
|
||||||
if (lbs)
|
|
||||||
getcfg(lbs->name, "URL", str, sizeof(str));
|
|
||||||
else
|
|
||||||
getcfg("global", "URL", str, sizeof(str));
|
|
||||||
|
|
||||||
/* if HTTP request comes from localhost, use localhost as
|
/* if HTTP request comes from localhost, use localhost as
|
||||||
absolute link (needed if running on DSL at home) */
|
absolute link (needed if running on DSL at home) */
|
||||||
if (!str[0] && strstr(http_host, "localhost")) {
|
if (!str[0] && strstr(http_host, "localhost")) {
|
||||||
strcpy(str, "http://localhost");
|
strlcpy(str, "http://localhost", sizeof(str));
|
||||||
if (elog_tcp_port != 80)
|
if (elog_tcp_port != 80)
|
||||||
sprintf(str + strlen(str), ":%d", elog_tcp_port);
|
sprintf(str + strlen(str), ":%d", elog_tcp_port);
|
||||||
strcat(str, "/");
|
strlcat(str, "/", sizeof(str));
|
||||||
}
|
|
||||||
|
|
||||||
if (!str[0]) {
|
|
||||||
/* assemble absolute path from host name and port */
|
|
||||||
sprintf(str, "http://%s", host_name);
|
|
||||||
if (elog_tcp_port != 80)
|
|
||||||
sprintf(str + strlen(str), ":%d", elog_tcp_port);
|
|
||||||
strcat(str, "/");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add trailing '/' if not present */
|
/* add trailing '/' if not present */
|
||||||
if (str[strlen(str) - 1] != '/')
|
if (str[strlen(str) - 1] != '/')
|
||||||
strcat(str, "/");
|
strlcat(str, "/", sizeof(str));
|
||||||
|
|
||||||
rsputs("Location: ");
|
|
||||||
rsputs(str);
|
|
||||||
|
|
||||||
/* add top group if existing and not logbook */
|
/* add top group if existing and not logbook */
|
||||||
if (!lbs && getcfg_topgroup()) {
|
if (!lbs && getcfg_topgroup()) {
|
||||||
rsputs(getcfg_topgroup());
|
strlcat(str, getcfg_topgroup(), sizeof(str));
|
||||||
rsputs("/");
|
strlcat(str, "/", sizeof(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(rel_path, "../", 3) == 0)
|
if (strncmp(rel_path, "../", 3) == 0)
|
||||||
rsputs(rel_path + 3);
|
strlcat(str, rel_path + 3, sizeof(str));
|
||||||
else if (strcmp(rel_path, ".") == 0) {
|
else if (strcmp(rel_path, ".") == 0) {
|
||||||
if (lbs)
|
if (lbs)
|
||||||
rsputs(lbs->name_enc);
|
strlcat(str, lbs->name_enc, sizeof(str));
|
||||||
} else if (rel_path[0] == '/')
|
} else if (rel_path[0] == '/')
|
||||||
rsputs(rel_path + 1);
|
strlcat(str, rel_path + 1, sizeof(str));
|
||||||
else {
|
else {
|
||||||
if (lbs) {
|
if (lbs) {
|
||||||
rsputs(lbs->name_enc);
|
strlcat(str, lbs->name_enc, sizeof(str));
|
||||||
rsputs("/");
|
strlcat(str, "/", sizeof(str));
|
||||||
rsputs(rel_path);
|
strlcat(str, rel_path, sizeof(str));
|
||||||
} else
|
} else
|
||||||
rsputs(rel_path);
|
strlcat(str, rel_path, sizeof(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rsputs("Location: ");
|
||||||
|
rsputs(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11358,7 +11382,12 @@ void show_config_page(LOGBOOK * lbs)
|
|||||||
rsprintf("</table></td></tr>\n");
|
rsprintf("</table></td></tr>\n");
|
||||||
|
|
||||||
rsprintf("<tr><td class=\"menuframe\"><span class=\"menu1\">\n");
|
rsprintf("<tr><td class=\"menuframe\"><span class=\"menu1\">\n");
|
||||||
rsprintf("<input type=submit name=cmd value=\"%s\">\n", loc("Change password"));
|
|
||||||
|
if (is_admin_user(logbook, getparam("unm")) ||
|
||||||
|
!getcfg(logbook, "allow password change", str, sizeof(str)) ||
|
||||||
|
atoi(str) == 1)
|
||||||
|
rsprintf("<input type=submit name=cmd value=\"%s\">\n", loc("Change password"));
|
||||||
|
|
||||||
rsprintf("<input type=submit name=cmd value=\"%s\" onClick=\"return chkrem();\">\n", loc("Remove user"));
|
rsprintf("<input type=submit name=cmd value=\"%s\" onClick=\"return chkrem();\">\n", loc("Remove user"));
|
||||||
|
|
||||||
if (is_admin_user(logbook, getparam("unm"))) {
|
if (is_admin_user(logbook, getparam("unm"))) {
|
||||||
@ -21075,7 +21104,8 @@ BOOL is_admin_user_global(char *user)
|
|||||||
BOOL check_user_password(LOGBOOK * lbs, char *user, char *password, char *redir)
|
BOOL check_user_password(LOGBOOK * lbs, char *user, char *password, char *redir)
|
||||||
{
|
{
|
||||||
char str[1000], str2[256], upwd[256], full_name[256], email[256];
|
char str[1000], str2[256], upwd[256], full_name[256], email[256];
|
||||||
int status;
|
int status, show_forgot_link, show_self_register;
|
||||||
|
;
|
||||||
|
|
||||||
if (user == NULL)
|
if (user == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -21094,6 +21124,9 @@ BOOL check_user_password(LOGBOOK * lbs, char *user, char *password, char *redir)
|
|||||||
|
|
||||||
/* check for "forgot password" */
|
/* check for "forgot password" */
|
||||||
if (isparam("cmd") && strcmp(getparam("cmd"), loc("Forgot")) == 0) {
|
if (isparam("cmd") && strcmp(getparam("cmd"), loc("Forgot")) == 0) {
|
||||||
|
if (getcfg(lbs->name, "forgot password link", str, sizeof(str)) && atoi(str) == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
show_forgot_pwd_page(lbs);
|
show_forgot_pwd_page(lbs);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -21173,17 +21206,26 @@ BOOL check_user_password(LOGBOOK * lbs, char *user, char *password, char *redir)
|
|||||||
rsprintf("%s</td></tr>\n", loc("Remember me on this computer"));
|
rsprintf("%s</td></tr>\n", loc("Remember me on this computer"));
|
||||||
}
|
}
|
||||||
|
|
||||||
rsprintf
|
show_forgot_link = (!getcfg(lbs->name, "allow password change", str, sizeof(str)) || atoi(str) == 1);
|
||||||
("<tr><td align=center colspan=2 class=\"dlgform\"><a href=\"?cmd=%s\">%s</a>",
|
show_self_register = (getcfg(lbs->name, "Self register", str, sizeof(str)) && atoi(str) > 0);
|
||||||
loc("Forgot"), loc("Forgot password?"));
|
|
||||||
|
|
||||||
if (getcfg(lbs->name, "Self register", str, sizeof(str)) && atoi(str) > 0) {
|
if (show_forgot_link || show_self_register)
|
||||||
|
rsprintf("<tr><td align=center colspan=2 class=\"dlgform\">\n");
|
||||||
|
|
||||||
|
if (show_forgot_link)
|
||||||
|
rsprintf("<a href=\"?cmd=%s\">%s</a>", loc("Forgot"), loc("Forgot password?"));
|
||||||
|
|
||||||
|
if (show_self_register) {
|
||||||
strcpy(str, loc("New user"));
|
strcpy(str, loc("New user"));
|
||||||
url_encode(str, sizeof(str));
|
url_encode(str, sizeof(str));
|
||||||
rsprintf(" <a href=\"?cmd=%s\">%s</a></td></tr>",
|
if (show_forgot_link)
|
||||||
str, loc("Register as new user"));
|
rsprintf(" ");
|
||||||
|
rsprintf("<a href=\"?cmd=%s\">%s</a></td></tr>", str, loc("Register as new user"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (show_forgot_link || show_self_register)
|
||||||
|
rsprintf("</td></tr>\n");
|
||||||
|
|
||||||
rsprintf
|
rsprintf
|
||||||
("<tr><td align=center colspan=2 class=\"dlgform\"><input type=submit value=\"%s\"></td></tr>",
|
("<tr><td align=center colspan=2 class=\"dlgform\"><input type=submit value=\"%s\"></td></tr>",
|
||||||
loc("Submit"));
|
loc("Submit"));
|
||||||
@ -23221,6 +23263,12 @@ void server_loop(void)
|
|||||||
return_buffer_size = 100000;
|
return_buffer_size = 100000;
|
||||||
return_buffer = xmalloc(return_buffer_size);
|
return_buffer = xmalloc(return_buffer_size);
|
||||||
|
|
||||||
|
/* determine logging level */
|
||||||
|
if (getcfg(NULL, "Logging Level", str, sizeof(str)))
|
||||||
|
_logging_level = atoi(str);
|
||||||
|
else
|
||||||
|
_logging_level = 2;
|
||||||
|
|
||||||
/* create a new socket */
|
/* create a new socket */
|
||||||
lsock = socket(AF_INET, SOCK_STREAM, 0);
|
lsock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (lsock == -1) {
|
if (lsock == -1) {
|
||||||
@ -23396,7 +23444,11 @@ void server_loop(void)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
eprintf("Server listening on port %d ...\n", elog_tcp_port);
|
sprintf(str, "Server listening on port %d ...\n", elog_tcp_port);
|
||||||
|
eprintf(str);
|
||||||
|
if (_logging_level > 0)
|
||||||
|
write_logfile(NULL, str);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
FD_ZERO(&readfds);
|
FD_ZERO(&readfds);
|
||||||
FD_SET(lsock, &readfds);
|
FD_SET(lsock, &readfds);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user