X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=client-src%2Frundump.c;h=61994496e16c9dea7e0e902af47dcc1cf8eafb4e;hb=fd48f3e498442f0cbff5f3606c7c403d0566150e;hp=5a9e50f53a798044bf46b322d5d97fcb8b723480;hpb=d3b2175e084f88c8736ad7073eacbf4670147aec;p=debian%2Famanda diff --git a/client-src/rundump.c b/client-src/rundump.c index 5a9e50f..6199449 100644 --- a/client-src/rundump.c +++ b/client-src/rundump.c @@ -33,8 +33,9 @@ * argv[2] will be argv[0] of the DUMP program * ... */ +#include "util.h" #include "amanda.h" -#include "version.h" +#include "conffile.h" int main(int argc, char **argv); @@ -44,10 +45,10 @@ int main(int argc, char **argv); #endif #if !defined(USE_RUNDUMP) -# define ERRMSG "rundump not enabled on this system.\n" +# define ERRMSG _("rundump not enabled on this system.\n") #else # if !defined(DUMP) && !defined(VXDUMP) && !defined(VDUMP) && !defined(XFSDUMP) -# define ERRMSG "DUMP not available on this system.\n" +# define ERRMSG _("DUMP not available on this system.\n") # else # undef ERRMSG # endif @@ -62,8 +63,18 @@ main( char *dump_program; int i; char *e; + char *cmdline; #endif /* ERRMSG */ + /* + * Configure program for internationalization: + * 1) Only set the message locale for now. + * 2) Set textdomain for all amanda related programs to "amanda" + * We don't want to be forced to support dozens of message catalogs. + */ + setlocale(LC_MESSAGES, "C"); + textdomain("amanda"); + safe_fd(-1, 0); safe_cd(); @@ -73,48 +84,39 @@ main( signal(SIGPIPE, SIG_IGN); dbopen(DBG_SUBDIR_CLIENT); + config_init(CONFIG_INIT_CLIENT, NULL); + if (argc < 3) { - error("%s: Need at least 3 arguments\n", debug_prefix_time(NULL)); + error(_("Need at least 3 arguments\n")); /*NOTREACHED*/ } - dbprintf(("%s: version %s\n", debug_prefix_time(NULL), version())); + dbprintf(_("version %s\n"), VERSION); #ifdef ERRMSG /* { */ - fprintf(stderr, ERRMSG); - dbprintf(("%s: %s", argv[0], ERRMSG)); + g_fprintf(stderr, ERRMSG); + dbprintf("%s: %s", argv[0], ERRMSG); dbclose(); return 1; #else /* } { */ - if(client_uid == (uid_t) -1) { - error("error [cannot find user %s in passwd file]\n", CLIENT_LOGIN); - /*NOTREACHED*/ - } - -#ifdef FORCE_USERID - if (getuid() != client_uid) { - error("error [must be invoked by %s]\n", CLIENT_LOGIN); - /*NOTREACHED*/ - } - - if (geteuid() != 0) { - error("error [must be setuid root]\n"); +#ifdef WANT_SETUID_CLIENT + check_running_as(RUNNING_AS_CLIENT_LOGIN | RUNNING_AS_UID_ONLY); + if (!become_root()) { + error(_("error [%s could not become root (is the setuid bit set?)]\n"), get_pname()); /*NOTREACHED*/ } -#endif /* FORCE_USERID */ - -#if !defined (DONT_SUID_ROOT) - setuid(0); +#else + check_running_as(RUNNING_AS_CLIENT_LOGIN); #endif /* skip argv[0] */ argc--; argv++; - dbprintf(("config: %s\n", argv[0])); + dbprintf(_("config: %s\n"), argv[0]); if (strcmp(argv[0], "NOCONFIG") != 0) dbrename(argv[0], DBG_SUBDIR_CLIENT); argc--; @@ -158,18 +160,24 @@ main( # endif #endif - dbprintf(("running: %s: ",dump_program)); - for (i=0; argv[i]; i++) - dbprintf(("%s ", argv[i])); - dbprintf(("\n")); + cmdline = stralloc(dump_program); + for (i = 1; argv[i]; i++) { + char *quoted; + + quoted = quote_string(argv[i]); + cmdline = vstrextend(&cmdline, " ", quoted, NULL); + amfree(quoted); + } + dbprintf(_("running: %s\n"), cmdline); + amfree(cmdline); execve(dump_program, argv, safe_env()); e = strerror(errno); - dbprintf(("failed (%s)\n", e)); + dbprintf(_("failed (%s)\n"), e); dbclose(); - fprintf(stderr, "rundump: could not exec %s: %s\n", dump_program, e); + g_fprintf(stderr, _("rundump: could not exec %s: %s\n"), dump_program, e); return 1; #endif /* } */ }