* ...
*/
#include "amanda.h"
-#include "version.h"
#include "util.h"
+#include "conffile.h"
int main(int argc, char **argv);
int i;
char *e;
char *dbf;
+ char *cmdline;
#endif
+ /*
+ * 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();
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(NULL));
+ error(_("Need at least 3 arguments\n"));
/*NOTREACHED*/
}
- dbprintf(("%s: version %s\n", debug_prefix(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(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;
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);
- /*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
-
-#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);
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
}