summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-06-27 10:46:41 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2011-06-27 10:46:41 +0200
commit9c76a88155c346666325339c5581a528d70b1f69 (patch)
treee1222d3317e5b32bbdd5d745bf538d5f27b12a1c /apt-pkg
parent21c1da10a011a341b0bb14904999442e64bb7584 (diff)
downloadapt-9c76a88155c346666325339c5581a528d70b1f69.tar.gz
* apt-pkg/deb/dpkgpm.cc:
- set permissions of term.log to root.adm and 644 (LP: #404724)
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/deb/dpkgpm.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index b37980b7..ca544e77 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -32,6 +32,8 @@
#include <algorithm>
#include <sstream>
#include <map>
+#include <pwd.h>
+#include <grp.h>
#include <termios.h>
#include <unistd.h>
@@ -667,7 +669,13 @@ bool pkgDPkgPM::OpenLog()
return _error->WarningE("OpenLog", _("Could not open file '%s'"), logfile_name.c_str());
setvbuf(term_out, NULL, _IONBF, 0);
SetCloseExec(fileno(term_out), true);
- chmod(logfile_name.c_str(), 0600);
+ struct passwd *pw;
+ struct group *gr;
+ pw = getpwnam("root");
+ gr = getgrnam("adm");
+ if (pw != NULL && gr != NULL)
+ chown(logfile_name.c_str(), pw->pw_uid, gr->gr_gid);
+ chmod(logfile_name.c_str(), 0644);
fprintf(term_out, "\nLog started: %s\n", timestr);
}