X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/e5af9e8ddd1ec06cceee9bafeb164da081912c80..477b12ff719d3749b8d8f85035bd6384fee9be0d:/server/dump.c diff --git a/server/dump.c b/server/dump.c index 74f1c46..d59eb6a 100644 --- a/server/dump.c +++ b/server/dump.c @@ -1,6 +1,6 @@ /* * This file is part of DisOrder. - * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell + * Copyright (C) 2004, 2005, 2007-2011 Richard Kettlewell * * 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 @@ -40,7 +40,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorder-dump [OPTIONS] --dump|--undump PATH\n" " disorder-dump [OPTIONS] --recompute-aliases\n" @@ -377,6 +377,8 @@ int main(int argc, char **argv) { FILE *fp; mem_init(); + if(!setlocale(LC_CTYPE, "")) + disorder_error(errno, "error calling setlocale"); while((n = getopt_long(argc, argv, "hVc:dDurRaPR", options, 0)) >= 0) { switch(n) { case 'h': help(); @@ -406,10 +408,9 @@ int main(int argc, char **argv) { disorder_fatal(0, "specify only a dump file name"); path = argv[optind]; } + config_per_user = 0; if(config_read(0, NULL)) disorder_fatal(0, "cannot read configuration"); - trackdb_init(recover|TRACKDB_MAY_CREATE); - trackdb_open(TRACKDB_NO_UPGRADE); if(dump) { /* We write to a temporary file and rename into place. We make * sure the permissions are tight from the start. */ @@ -418,6 +419,8 @@ int main(int argc, char **argv) { disorder_fatal(errno, "error opening %s", tmp); if(!(fp = fdopen(fd, "w"))) disorder_fatal(errno, "fdopen on %s", tmp); + trackdb_init(recover|TRACKDB_MAY_CREATE); + trackdb_open(TRACKDB_NO_UPGRADE); do_dump(fp, tmp); if(fclose(fp) < 0) disorder_fatal(errno, "error closing %s", tmp); if(rename(tmp, path) < 0) @@ -432,6 +435,8 @@ int main(int argc, char **argv) { * if new ones are created */ if(getuid() == 0) disorder_info("you might need to chown database files"); + trackdb_init(recover|TRACKDB_MAY_CREATE); + trackdb_open(TRACKDB_NO_UPGRADE); do_undump(fp, path, remove_pathless); xfclose(fp); } else if(recompute) {