mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-14 20:33:48 +00:00
Create password file if not present
SVN revision: 1317
This commit is contained in:
parent
eb56b71b47
commit
5532a6bf1e
36
src/elogd.c
36
src/elogd.c
@ -6,6 +6,9 @@
|
|||||||
Contents: Web server program for Electronic Logbook ELOG
|
Contents: Web server program for Electronic Logbook ELOG
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.624 2005/04/13 19:39:46 ritt
|
||||||
|
Create password file if not present
|
||||||
|
|
||||||
Revision 1.623 2005/04/13 08:05:05 ritt
|
Revision 1.623 2005/04/13 08:05:05 ritt
|
||||||
Fixed bug with conditions and '&'
|
Fixed bug with conditions and '&'
|
||||||
|
|
||||||
@ -19029,7 +19032,7 @@ BOOL convert_password_file(char *file_name)
|
|||||||
|
|
||||||
PMXML_NODE load_password_file(LOGBOOK * lbs)
|
PMXML_NODE load_password_file(LOGBOOK * lbs)
|
||||||
{
|
{
|
||||||
PMXML_NODE xml_tree;
|
PMXML_NODE root, list, xml_tree;
|
||||||
char str[256], line[256], file_name[256];
|
char str[256], line[256], file_name[256];
|
||||||
int fh;
|
int fh;
|
||||||
|
|
||||||
@ -19049,24 +19052,23 @@ PMXML_NODE load_password_file(LOGBOOK * lbs)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
close(fh);
|
close(fh);
|
||||||
fh = open(file_name, O_RDONLY);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fh < 0) {
|
/* put empty XML tree into password file */
|
||||||
sprintf(str, loc("Cannot open file <b>%s</b>"), file_name);
|
printf("Create empty password file \"%s\" ...\n", file_name);
|
||||||
strcat(str, ": ");
|
root = mxml_create_root_node();
|
||||||
strlcat(str, strerror(errno), sizeof(str));
|
list = mxml_add_node(root, "list", NULL);
|
||||||
show_error(str);
|
mxml_write_tree(file_name, root);
|
||||||
return NULL;
|
mxml_free_tree(root);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
/* check if in XML format, otherwise convert it */
|
/* check if in XML format, otherwise convert it */
|
||||||
line[0] = 0;
|
line[0] = 0;
|
||||||
read(fh, line, sizeof(line));
|
read(fh, line, sizeof(line));
|
||||||
close(fh);
|
close(fh);
|
||||||
if (strstr(line, "<?xml") == 0) {
|
if (strstr(line, "<?xml") == 0) {
|
||||||
if (!convert_password_file(file_name))
|
if (!convert_password_file(file_name))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((xml_tree = mxml_parse_file(file_name, str, sizeof(str))) == NULL) {
|
if ((xml_tree = mxml_parse_file(file_name, str, sizeof(str))) == NULL) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user