mirror of
https://github.com/moparisthebest/pacman
synced 2025-03-01 01:41:52 -05:00
Warn when directory ownership differs between filesystem and package
We currently only warn if a directory's permissions differ, but using -Qkk on my system shows that directory permissions tend to change in packages reasonably frequently without notice. Provide a warning in such cases so that it can be altered. Example output: (1/1) reinstalling nginx warning: directory ownership differs on /var/lib/nginx/proxy/ filesystem: 33:0 package: 0:0 Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
640324f1d4
commit
e81faa9d6d
@ -215,18 +215,32 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
|
|||||||
} else {
|
} else {
|
||||||
if(S_ISDIR(lsbuf.st_mode)) {
|
if(S_ISDIR(lsbuf.st_mode)) {
|
||||||
if(S_ISDIR(entrymode)) {
|
if(S_ISDIR(entrymode)) {
|
||||||
|
uid_t entryuid = archive_entry_uid(entry);
|
||||||
|
gid_t entrygid = archive_entry_gid(entry);
|
||||||
|
|
||||||
/* case 6: existing dir, ignore it */
|
/* case 6: existing dir, ignore it */
|
||||||
if(lsbuf.st_mode != entrymode) {
|
if(lsbuf.st_mode != entrymode) {
|
||||||
/* if filesystem perms are different than pkg perms, warn user */
|
/* if filesystem perms are different than pkg perms, warn user */
|
||||||
mode_t mask = 07777;
|
mode_t mask = 07777;
|
||||||
_alpm_log(handle, ALPM_LOG_WARNING, _("directory permissions differ on %s\n"
|
_alpm_log(handle, ALPM_LOG_WARNING, _("directory permissions differ on %s\n"
|
||||||
"filesystem: %o package: %o\n"), filename, lsbuf.st_mode & mask,
|
"filesystem: %o package: %o\n"), filename, lsbuf.st_mode & mask,
|
||||||
entrymode & mask);
|
entrymode & mask);
|
||||||
alpm_logaction(handle, ALPM_CALLER_PREFIX,
|
alpm_logaction(handle, ALPM_CALLER_PREFIX,
|
||||||
"warning: directory permissions differ on %s\n"
|
"warning: directory permissions differ on %s\n"
|
||||||
"filesystem: %o package: %o\n", filename, lsbuf.st_mode & mask,
|
"filesystem: %o package: %o\n", filename, lsbuf.st_mode & mask,
|
||||||
entrymode & mask);
|
entrymode & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((entryuid != lsbuf.st_uid) || (entrygid != lsbuf.st_gid)) {
|
||||||
|
_alpm_log(handle, ALPM_LOG_WARNING, _("directory ownership differs on %s\n"
|
||||||
|
"filesystem: %u:%u package: %u:%u\n"), filename,
|
||||||
|
lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
|
||||||
|
alpm_logaction(handle, ALPM_CALLER_PREFIX,
|
||||||
|
"warning: directory ownership differs on %s\n"
|
||||||
|
"filesystem: %u:%u package: %u:%u\n", filename,
|
||||||
|
lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
|
||||||
|
}
|
||||||
|
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
|
_alpm_log(handle, ALPM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
|
||||||
filename);
|
filename);
|
||||||
archive_read_data_skip(archive);
|
archive_read_data_skip(archive);
|
||||||
|
@ -106,9 +106,12 @@ static int check_file_time(const char *pkgname, const char *filepath,
|
|||||||
{
|
{
|
||||||
if(st->st_mtime != archive_entry_mtime(entry)) {
|
if(st->st_mtime != archive_entry_mtime(entry)) {
|
||||||
if(backup) {
|
if(backup) {
|
||||||
printf("%s%s%s: ", config->colstr.title, _("backup file"), config->colstr.nocolor);
|
if(!config->quiet) {
|
||||||
printf(_("%s: %s (Modification time mismatch)\n"),
|
printf("%s%s%s: ", config->colstr.title, _("backup file"),
|
||||||
pkgname, filepath);
|
config->colstr.nocolor);
|
||||||
|
printf(_("%s: %s (Modification time mismatch)\n"),
|
||||||
|
pkgname, filepath);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(!config->quiet) {
|
if(!config->quiet) {
|
||||||
@ -150,9 +153,12 @@ static int check_file_size(const char *pkgname, const char *filepath,
|
|||||||
{
|
{
|
||||||
if(st->st_size != archive_entry_size(entry)) {
|
if(st->st_size != archive_entry_size(entry)) {
|
||||||
if(backup) {
|
if(backup) {
|
||||||
printf("%s%s%s: ", config->colstr.title, _("backup file"), config->colstr.nocolor);
|
if(!config->quiet) {
|
||||||
printf(_("%s: %s (Size mismatch)\n"),
|
printf("%s%s%s: ", config->colstr.title, _("backup file"),
|
||||||
pkgname, filepath);
|
config->colstr.nocolor);
|
||||||
|
printf(_("%s: %s (Size mismatch)\n"),
|
||||||
|
pkgname, filepath);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(!config->quiet) {
|
if(!config->quiet) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user