From: Francois-Xavier Le Bail Date: Tue, 8 Sep 2015 15:43:21 +0000 (+0200) Subject: Print program_name instead of "tcpdump" X-Git-Tag: tcpdump-4.8.0~164 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/612d417d9a194ae530b63e12c1fb9bd263077729 Print program_name instead of "tcpdump" Moreover: Fix indent --- diff --git a/tcpdump.c b/tcpdump.c index 063ac7b4..f6313064 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -479,7 +479,8 @@ droproot(const char *username, const char *chroot_dir) struct passwd *pw = NULL; if (chroot_dir && !username) { - fprintf(stderr, "tcpdump: Chroot without dropping root is insecure\n"); + fprintf(stderr, "%s: Chroot without dropping root is insecure\n", + program_name); exit(1); } @@ -487,8 +488,8 @@ droproot(const char *username, const char *chroot_dir) if (pw) { if (chroot_dir) { if (chroot(chroot_dir) != 0 || chdir ("/") != 0) { - fprintf(stderr, "tcpdump: Couldn't chroot/chdir to '%.64s': %s\n", - chroot_dir, pcap_strerror(errno)); + fprintf(stderr, "%s: Couldn't chroot/chdir to '%.64s': %s\n", + program_name, chroot_dir, pcap_strerror(errno)); exit(1); } } @@ -504,11 +505,11 @@ droproot(const char *username, const char *chroot_dir) #else if (initgroups(pw->pw_name, pw->pw_gid) != 0 || setgid(pw->pw_gid) != 0 || setuid(pw->pw_uid) != 0) { - fprintf(stderr, "tcpdump: Couldn't change to '%.32s' uid=%lu gid=%lu: %s\n", - username, - (unsigned long)pw->pw_uid, - (unsigned long)pw->pw_gid, - pcap_strerror(errno)); + fprintf(stderr, "%s: Couldn't change to '%.32s' uid=%lu gid=%lu: %s\n", + program_name, username, + (unsigned long)pw->pw_uid, + (unsigned long)pw->pw_gid, + pcap_strerror(errno)); exit(1); } else { @@ -517,8 +518,8 @@ droproot(const char *username, const char *chroot_dir) #endif /* HAVE_LIBCAP_NG */ } else { - fprintf(stderr, "tcpdump: Couldn't find user '%.32s'\n", - username); + fprintf(stderr, "%s: Couldn't find user '%.32s'\n", + program_name, username); exit(1); } #ifdef HAVE_LIBCAP_NG @@ -1129,7 +1130,7 @@ main(int argc, char **argv) #endif case 'z': zflag = strdup(optarg); - if (zflag == NULL) + if (zflag == NULL) error("Unable to allocate memory for -z argument"); break;