Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rejmerge ignores directory permissions #6

Open
sighook opened this issue Jun 15, 2023 · 1 comment
Open

rejmerge ignores directory permissions #6

sighook opened this issue Jun 15, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@sighook
Copy link
Contributor

sighook commented Jun 15, 2023

Reference: https://crux.nu/bugs/index.php?do=details&task_id=379&project=1&pagenum=2

if a directory, rejected by pkgadd, has new/other permissions or user/group
than the installed one, rejmerge should do an update which the current
version refused to do.

How to reproduce:

1. echo >> /var/spool/cron/crontabs/root
2. chown daemon /var/spool/cron/crontabs
3. cd /usr/ports/core/dcron
4. pkgmk -u

pkgadd reports something like that:

pkgadd: rejecting var/spool/cron/crontabs/, keeping existing version
pkgadd: rejecting var/spool/cron/crontabs/root, keeping existing'version

5. run rejmerge

Note:
step 1. above is necessary because pkgadd doesn't add empty directories to
/var/lib/pkg/rejected, which might be considered as bug as well.

Attached patch adds a check of directory permissions to rejmerge.

diff --git a/rejmerge.8.in b/rejmerge.8.in
index cc05c4c..7fc5361 100644
--- a/rejmerge.8.in
+++ b/rejmerge.8.in
@@ -73,6 +73,6 @@ Directory where rejected files are stored.
 .SH SEE ALSO
 pkgadd(8), pkgrm(8), pkginfo(8), pkgmk(8)
 .SH COPYRIGHT
-rejmerge (pkgutils) is Copyright (c) 2000-2005 Per Liden and Copyright (c) 2006-2010 CRUX team (http://crux.nu).
+rejmerge (pkgutils) is Copyright (c) 2000-2005 Per Liden and Copyright (c) 2006-2012 CRUX team (http://crux.nu).
 rejmerge (pkgutils) is licensed through the GNU General Public License.
 Read the COPYING file for the complete license.
diff --git a/rejmerge.in b/rejmerge.in
index d6b479a..ccc3b3a 100755
--- a/rejmerge.in
+++ b/rejmerge.in
@@ -3,7 +3,7 @@
 #  rejmerge (pkgutils)
 # 
 #  Copyright (c) 2000-2005 Per Liden
-#  Copyright (c) 2006-2010 by CRUX team (http://crux.nu)
+#  Copyright (c) 2006-2012 by CRUX team (http://crux.nu)
 # 
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
@@ -284,6 +284,23 @@ main() {
 		fi
 	done
 
+	# Check permissions of directories
+	for DIR in $(find $REJECTED_DIR -depth -type d); do
+
+		local INSTALLED_DIR="${DIR##$REJECTED_DIR}"
+
+		if [ -d "$INSTALLED_DIR" -a -d $DIR ]; then
+
+			local STAT_DIR1=$(stat -c '%A %U %G' "$INSTALLED_DIR")
+			local STAT_DIR2=$(stat -c '%A %U %G' "$DIR")
+
+			if [ "$STAT_DIR1" != "$STAT_DIR2" ]; then
+				REJECTED_FILES_FOUND="yes"
+				permissions_menu "$INSTALLED_DIR" "$DIR"
+			fi
+		fi
+	done
+
 	# Remove empty directories
 	for DIR in $(find $REJECTED_DIR -depth -type d); do
 		if [ "$DIR" != "$REJECTED_DIR" ]; then
@sighook sighook added the bug Something isn't working label Jun 15, 2023
@sighook
Copy link
Contributor Author

sighook commented Jun 30, 2023

Note:
step 1. above is necessary because pkgadd doesn't add empty directories to
/var/lib/pkg/rejected, which might be considered as bug as well.

???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

1 participant