From 5532a6bf1e369cca0d957424d1102622cc15a73e Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Wed, 13 Apr 2005 19:39:46 +0000 Subject: [PATCH] Create password file if not present SVN revision: 1317 --- src/elogd.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/elogd.c b/src/elogd.c index c14ce63a..1ba59422 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $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 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 xml_tree; + PMXML_NODE root, list, xml_tree; char str[256], line[256], file_name[256]; int fh; @@ -19049,24 +19052,23 @@ PMXML_NODE load_password_file(LOGBOOK * lbs) return NULL; } close(fh); - fh = open(file_name, O_RDONLY); - } + + /* put empty XML tree into password file */ + printf("Create empty password file \"%s\" ...\n", file_name); + root = mxml_create_root_node(); + list = mxml_add_node(root, "list", NULL); + mxml_write_tree(file_name, root); + mxml_free_tree(root); + } else { - if (fh < 0) { - sprintf(str, loc("Cannot open file %s"), file_name); - strcat(str, ": "); - strlcat(str, strerror(errno), sizeof(str)); - show_error(str); - return NULL; - } - - /* check if in XML format, otherwise convert it */ - line[0] = 0; - read(fh, line, sizeof(line)); - close(fh); - if (strstr(line, "