Skip to contentSkip to conversation

PAM Namespace: expand $HOME

RFC PATCH Superseded Xavier Toth 1 participant 1 message Nov 26, 2007 SELinux security module

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 2/10 PAM Namespace: expand $HOME

This patch expands $HOME when it is used in the directory portion of a namespace.conf configuration line to specify subdirectories of the home directory for example $HOME/.mozilla.

--- Linux-PAM-0.99.8.1/modules/pam_namespace/pam_namespace.c 2007-11-14
08:30:46.000000000 -0600
+++ Linux-PAM-0.99.8.1.new/modules/pam_namespace/pam_namespace.c 2007-11-14
08:33:13.000000000 -0600
@@ -207,8 +207,10 @@
* the "$HOME" string with the user's home directory that is
* passed in as an argument.
*/
- if (strcmp(dir, "$HOME") == 0) {
- dir = home;
+ if (strncmp(dir, "$HOME", 5) == 0) {

+            char *expanded = alloca(strlen(home) + strlen(dir) - 5 + 1);
+            sprintf(expanded, "%s%s", home, dir + 5);
+            dir = expanded;
     }

     /*

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.