]> err.no Git - util-linux/commitdiff
libmount: fix utab file and dir modes, add new debug messages
authorKarel Zak <kzak@redhat.com>
Tue, 23 Nov 2010 19:39:55 +0000 (20:39 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Jan 2011 11:28:46 +0000 (12:28 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/mount/src/context.c
shlibs/mount/src/context_mount.c
shlibs/mount/src/tab_parse.c
shlibs/mount/src/tab_update.c
shlibs/mount/src/utils.c

index 2cc76a0adcd0ed9cf2a9f681f9a30e960461405b..6ee68c16a20372efa7424eb50e2aa2ea76bc7c1b 100644 (file)
@@ -46,7 +46,7 @@ mnt_context *mnt_new_context()
 
        if (!cxt->mtab_writable)
                /* use /dev/.mount/utab if /etc/mtab is useless */
-               mnt_has_regular_mtab(&cxt->utab_path, &cxt->utab_writable);
+               mnt_has_regular_utab(&cxt->utab_path, &cxt->utab_writable);
 
        return cxt;
 }
@@ -1054,11 +1054,18 @@ int mnt_context_prepare_update(mnt_context *cxt)
                /* Don't try to touch mtab if umounting root FS */
                cxt->flags |= MNT_FL_NOMTAB;
 
-       if ((cxt->flags & MNT_FL_NOMTAB) || cxt->helper)
+       if (cxt->flags & MNT_FL_NOMTAB) {
+               DBG(CXT, mnt_debug_h(cxt, "skip update: NOMTAB flag"));
                return 0;
-       if (!cxt->mtab_writable && !cxt->utab_writable)
+       }
+       if (cxt->helper) {
+               DBG(CXT, mnt_debug_h(cxt, "skip update: external helper"));
                return 0;
-
+       }
+       if (!cxt->mtab_writable && !cxt->utab_writable) {
+               DBG(CXT, mnt_debug_h(cxt, "skip update: no writable destination"));
+               return 0;
+       }
        if (!cxt->update) {
                cxt->update = mnt_new_update(!cxt->mtab_writable);
                if (!cxt->update)
@@ -1386,6 +1393,9 @@ int main(int argc, char *argv[])
        { "--umount", test_umount, "[-t <type>] [-f][-l][-r] <src>|<target>" },
        { NULL }};
 
+
+       umask(S_IWGRP|S_IWOTH); /* to be compatible with mount(8) */
+
        return mnt_run_test(tss, argc, argv);
 }
 
index 7b0a9c12648f56fc5ff395edf68d6d36167eec67..960126d688bba819ae734f91117a55f2f6ffe8ee 100644 (file)
@@ -385,6 +385,8 @@ static int do_mount_by_pattern(mnt_context *cxt, const char *pattern)
                 */
                char *p, *p0;
 
+               DBG(CXT, mnt_debug_h(cxt, "tring mount by FS pattern list"));
+
                p0 = p = strdup(pattern);
                if (!p)
                        return -ENOMEM;
@@ -405,6 +407,8 @@ static int do_mount_by_pattern(mnt_context *cxt, const char *pattern)
        /*
         * try /etc/filesystems and /proc/filesystems
         */
+       DBG(CXT, mnt_debug_h(cxt, "tring mount by filesystems lists"));
+
        rc = mnt_get_filesystems(&filesystems, neg ? pattern : NULL);
        if (rc)
                return rc;
index af5008328c850640693ca36e645caec2e68d5a44..21f64336c667e5be707e1f5d7ec700573f80d97d 100644 (file)
@@ -631,6 +631,9 @@ int mnt_tab_parse_mtab(mnt_tab *tb, const char *filename)
        const char *utab = NULL;
 
        if (mnt_has_regular_mtab(&filename, NULL)) {
+
+               DBG(TAB, mnt_debug_h(tb, "force %s usage", filename));
+
                rc = mnt_tab_parse_file(tb, filename);
                if (!rc)
                        return 0;
@@ -647,11 +650,11 @@ int mnt_tab_parse_mtab(mnt_tab *tb, const char *filename)
                return mnt_tab_parse_file(tb, _PATH_PROC_MOUNTS);
 
        /*
-        * try to read userspace specific information from /dev/.mount/utabs/
+        * try to read userspace specific information from /dev/.mount/utabs
         */
        utab = mnt_get_utab_path();
        if (utab) {
-               mnt_tab *u_tb = mnt_new_tab_from_dir(utab);
+               mnt_tab *u_tb = mnt_new_tab_from_file(utab);
 
                if (u_tb) {
                        mnt_fs *u_fs;
index 4b4f0adddce2a59afde030423488b6e2dddb49ce..f9d4e5f0699735742f12d6115c4d76366fc9fec2 100644 (file)
@@ -458,7 +458,8 @@ static int utab_lock(const char *filename)
 
        DBG(UPDATE, mnt_debug("%s: locking", lfile));
 
-       fd = open(lfile, O_RDONLY|O_CREAT|O_CLOEXEC, S_IRUSR|S_IWUSR);
+       fd = open(lfile, O_RDONLY|O_CREAT|O_CLOEXEC, S_IWUSR|
+                                                    S_IRUSR|S_IRGRP|S_IROTH);
        free(lfile);
 
        if (fd < 0)
index 6af8d14f4649e58671a002625043c23b9696377a..468b0bb3dce9756327c50168ed20dcb33897c0ac 100644 (file)
@@ -37,6 +37,8 @@
 
 char *mnt_getenv_safe(const char *arg)
 {
+       return getenv(arg);
+
        if ((getuid() != geteuid()) || (getgid() != getegid()))
                return NULL;
 #if HAVE_PRCTL
@@ -510,7 +512,8 @@ static int try_write(const char *filename)
        if (!filename)
                return -EINVAL;
 
-       fd = open(filename, O_RDWR, 0644);
+       fd = open(filename, O_RDWR|O_CREAT, S_IWUSR| \
+                                           S_IRUSR|S_IRGRP|S_IROTH);
        if (fd >= 0) {
                close(fd);
                return 0;
@@ -612,7 +615,9 @@ int mnt_has_regular_utab(const char **utab, int *writable)
 
                stripoff_last_component(dirname);       /* remove filename */
 
-               rc = mkdir(dirname, 755);
+               rc = mkdir(dirname, S_IWUSR|
+                                   S_IRUSR|S_IRGRP|S_IROTH|
+                                   S_IXUSR|S_IXGRP|S_IXOTH);
                free(dirname);
                if (rc && errno != EEXIST)
                        goto done;                      /* probably EACCES */