savefile: don't try to change ownership of stdout

I case we already opened savefile we want to change ownership of the file to the
given user (tcpdump by default), but we shouldn't do so when dumping to stdout
is requested.

Resolves: #1015767
This commit is contained in:
Michal Sekletar 2013-10-07 15:40:31 +02:00
parent d6467ea986
commit d115fc0d58
2 changed files with 8 additions and 5 deletions

View File

@ -1,6 +1,6 @@
diff -up tcpdump-4.4.0/tcpdump.1.in.eperm tcpdump-4.4.0/tcpdump.1.in diff -up tcpdump-4.4.0/tcpdump.1.in.eperm tcpdump-4.4.0/tcpdump.1.in
--- tcpdump-4.4.0/tcpdump.1.in.eperm 2013-05-06 13:24:27.832436506 +0200 --- tcpdump-4.4.0/tcpdump.1.in.eperm 2013-10-07 15:21:26.795602764 +0200
+++ tcpdump-4.4.0/tcpdump.1.in 2013-05-06 13:24:27.839436511 +0200 +++ tcpdump-4.4.0/tcpdump.1.in 2013-10-07 15:21:26.800602762 +0200
@@ -221,6 +221,9 @@ have the name specified with the @@ -221,6 +221,9 @@ have the name specified with the
flag, with a number after it, starting at 1 and continuing upward. flag, with a number after it, starting at 1 and continuing upward.
The units of \fIfile_size\fP are millions of bytes (1,000,000 bytes, The units of \fIfile_size\fP are millions of bytes (1,000,000 bytes,
@ -24,7 +24,7 @@ diff -up tcpdump-4.4.0/tcpdump.1.in.eperm tcpdump-4.4.0/tcpdump.1.in
selects which packets will be dumped. selects which packets will be dumped.
diff -up tcpdump-4.4.0/tcpdump.c.eperm tcpdump-4.4.0/tcpdump.c diff -up tcpdump-4.4.0/tcpdump.c.eperm tcpdump-4.4.0/tcpdump.c
--- tcpdump-4.4.0/tcpdump.c.eperm 2013-03-24 22:49:18.000000000 +0100 --- tcpdump-4.4.0/tcpdump.c.eperm 2013-03-24 22:49:18.000000000 +0100
+++ tcpdump-4.4.0/tcpdump.c 2013-05-06 13:28:40.929602618 +0200 +++ tcpdump-4.4.0/tcpdump.c 2013-10-07 15:22:26.360590143 +0200
@@ -1426,11 +1426,24 @@ main(int argc, char **argv) @@ -1426,11 +1426,24 @@ main(int argc, char **argv)
} }
#endif /* HAVE_CAP_NG_H */ #endif /* HAVE_CAP_NG_H */
@ -66,7 +66,7 @@ diff -up tcpdump-4.4.0/tcpdump.c.eperm tcpdump-4.4.0/tcpdump.c
+ if (!pwd) + if (!pwd)
+ error("Couldn't find user '%s'", username); + error("Couldn't find user '%s'", username);
+ +
+ if (chown(dumpinfo.CurrentFileName, pwd->pw_uid, pwd->pw_gid) < 0) + if (strcmp(WFileName, "-") && chown(dumpinfo.CurrentFileName, pwd->pw_uid, pwd->pw_gid) < 0)
+ error("Couldn't change ownership of savefile"); + error("Couldn't change ownership of savefile");
+ +
+ if (username || chroot_dir) + if (username || chroot_dir)

View File

@ -2,7 +2,7 @@ Summary: A network traffic monitoring tool
Name: tcpdump Name: tcpdump
Epoch: 14 Epoch: 14
Version: 4.4.0 Version: 4.4.0
Release: 2%{?dist} Release: 3%{?dist}
License: BSD with advertising License: BSD with advertising
URL: http://www.tcpdump.org URL: http://www.tcpdump.org
Group: Applications/Internet Group: Applications/Internet
@ -95,6 +95,9 @@ exit 0
%{_mandir}/man8/tcpdump.8* %{_mandir}/man8/tcpdump.8*
%changelog %changelog
* Mon Oct 7 2013 Michal Sekletar <msekleta@redhat.com> - 14:4.4.0-3
- don't try to change ownership of stdout (#1015767)
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 14:4.4.0-2 * Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 14:4.4.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild