X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=client-src%2Frundump.c;h=9788e97e27296084fce248d9dcb434d03f2863a8;hb=HEAD;hp=347da0a356e4c27ea914b0125d91e2ef0b616abf;hpb=1194fb66aa28d9929c3f2bef3cc6c1c3f40a60a4;p=debian%2Famanda diff --git a/client-src/rundump.c b/client-src/rundump.c index 347da0a..9788e97 100644 --- a/client-src/rundump.c +++ b/client-src/rundump.c @@ -1,6 +1,7 @@ /* * Amanda, The Advanced Maryland Automatic Network Disk Archiver * Copyright (c) 1991-1998 University of Maryland at College Park + * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved. * All Rights Reserved. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -24,14 +25,20 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: rundump.c,v 1.28 2006/01/14 04:37:18 paddy_s Exp $ + * $Id: rundump.c,v 1.33 2006/07/25 18:27:56 martinea Exp $ * * runs DUMP program as root + * + * argv[0] is the rundump program name + * argv[1] is the config name or NOCONFIG + * argv[2] will be argv[0] of the DUMP program + * ... */ #include "amanda.h" -#include "version.h" +#include "util.h" +#include "conffile.h" -int main P((int argc, char **argv)); +int main(int argc, char **argv); #if defined(VDUMP) || defined(XFSDUMP) # undef USE_RUNDUMP @@ -39,25 +46,41 @@ int main P((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 #endif -int main(argc, argv) -int argc; -char **argv; +int +main( + int argc, + char ** argv) { #ifndef ERRMSG char *dump_program; int i; char *e; + char *cmdline; #endif /* ERRMSG */ + if (argc > 1 && argv && argv[1] && g_str_equal(argv[1], "--version")) { + printf("rundump-%s\n", VERSION); + return (0); + } + + /* + * 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(); @@ -66,33 +89,44 @@ char **argv; /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); - dbopen(); - dbprintf(("%s: version %s\n", argv[0], version())); + dbopen(DBG_SUBDIR_CLIENT); + config_init(CONFIG_INIT_CLIENT, NULL); + + if (argc < 3) { + error(_("Need at least 3 arguments\n")); + /*NOTREACHED*/ + } + + 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); +#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*/ } +#else + check_running_as(RUNNING_AS_CLIENT_LOGIN); +#endif -#ifdef FORCE_USERID - if (getuid() != client_uid) - error("error [must be invoked by %s]\n", CLIENT_LOGIN); - - if (geteuid() != 0) - error("error [must be setuid root]\n"); -#endif /* FORCE_USERID */ + /* skip argv[0] */ + argc--; + argv++; -#if !defined (DONT_SUID_ROOT) - setuid(0); -#endif + dbprintf(_("config: %s\n"), argv[0]); + if (strcmp(argv[0], "NOCONFIG") != 0) + dbrename(argv[0], DBG_SUBDIR_CLIENT); + argc--; + argv++; #ifdef XFSDUMP @@ -132,18 +166,24 @@ char **argv; # 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 /* } */ }