X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=client-src%2Fruntar.c;h=194a00a4ac8ff8798ce3acd213c6214ef35fec5a;hb=691567b16c13087b31ee4c2b6d038e57872fae82;hp=f088ea13bf871f280308324e35b6c587d499c240;hpb=d3b2175e084f88c8736ad7073eacbf4670147aec;p=debian%2Famanda diff --git a/client-src/runtar.c b/client-src/runtar.c index f088ea1..194a00a 100644 --- a/client-src/runtar.c +++ b/client-src/runtar.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 @@ -34,8 +35,8 @@ * ... */ #include "amanda.h" -#include "version.h" #include "util.h" +#include "conffile.h" int main(int argc, char **argv); @@ -48,8 +49,23 @@ main( int i; char *e; char *dbf; + char *cmdline; #endif + if (argc > 1 && argv && argv[1] && g_str_equal(argv[1], "--version")) { + printf("runtar-%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(); @@ -59,23 +75,24 @@ 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); if (strcmp(argv[3], "--create") != 0) { - error("%s: Can only be used to create tar archives\n", - debug_prefix_time(NULL)); + error(_("Can only be used to create tar archives\n")); /*NOTREACHED*/ } #ifndef GNUTAR - fprintf(stderr,"gnutar not available on this system.\n"); - dbprintf(("%s: gnutar not available on this system.\n", argv[0])); + g_fprintf(stderr,_("gnutar not available on this system.\n")); + dbprintf(_("%s: gnutar not available on this system.\n"), argv[0]); dbclose(); return 1; @@ -90,60 +107,50 @@ main( if ((version_file = popen(GNUTAR " --version 2>&1", "r")) != NULL) { if (fgets(version_buf, (int)sizeof(version_buf), version_file) != NULL) { - dbprintf((GNUTAR " version: %s\n", version_buf)); + dbprintf(_(GNUTAR " version: %s\n"), version_buf); } else { if (ferror(version_file)) { - dbprintf((GNUTAR " version: Read failure: %s\n", strerror(errno))); + dbprintf(_(GNUTAR " version: Read failure: %s\n"), strerror(errno)); } else { - dbprintf((GNUTAR " version: Read failure; EOF\n")); + dbprintf(_(GNUTAR " version: Read failure; EOF\n")); } } } else { - dbprintf((GNUTAR " version: unavailable: %s\n", strerror(errno))); + dbprintf(_(GNUTAR " version: unavailable: %s\n"), strerror(errno)); } } while(0); - 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); +#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*/ } - - if (geteuid() != 0) { - error("error [must be setuid root]\n"); - /*NOTREACHED*/ - } -#endif - -#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--; argv++; - - dbprintf(("running: %s: ",GNUTAR)); - for (i=0; argv[i]; i++) { + cmdline = stralloc(GNUTAR); + for (i = 1; argv[i]; i++) { char *quoted; quoted = quote_string(argv[i]); - dbprintf(("'%s' ", quoted)); + cmdline = vstrextend(&cmdline, " ", quoted, NULL); amfree(quoted); } - dbprintf(("\n")); + dbprintf(_("running: %s\n"), cmdline); + amfree(cmdline); + dbf = dbfn(); if (dbf) { dbf = stralloc(dbf); @@ -155,10 +162,10 @@ main( e = strerror(errno); dbreopen(dbf, "more"); amfree(dbf); - dbprintf(("execve of %s failed (%s)\n", GNUTAR, e)); + dbprintf(_("execve of %s failed (%s)\n"), GNUTAR, e); dbclose(); - fprintf(stderr, "runtar: could not exec %s: %s\n", GNUTAR, e); + g_fprintf(stderr, _("runtar: could not exec %s: %s\n"), GNUTAR, e); return 1; #endif }