Hi,

I think I've found 2 bugs in hugeadm 2.17.  I am using --global-create-mounts
to create a global mount point.  I have noticed that the permissions were not
correct on all of my systems.  It was pretty surprising.

This looks like a bug in hugeadm.cc:558

          /* Check if mtab is a symlink */
          useMtab = (readlink(MOUNTED, &dummy, 1) < 0);
          if (!useMtab) {
           /* No need updating mtab */
              return 0;
           }

        /* snip */

        if (chown(path, uid, gid)) {
            ERROR("Unable to change ownership of %s, error: %s\n",
                path, strerror(errno));
            return 1;
        }

        if (chmod(path, mode)) {
            ERROR("Unable to set permissions on %s, error: %s\n",
                path, strerror(errno));
            return 1;
        }

If mtab is NOT a symlink, the code will bail and will not run the
chmod/chown.

Additionally the manpage mentions that the permissions should be 1777.
I do not see the sticky bit set at all:
    if (opt_global_mounts) {
        snprintf(base, PATH_MAX, "%s/global", MOUNT_DIR);
        create_mounts(NULL, NULL, base, S_IRWXU | S_IRWXG | S_IRWXO);
    }

I am pasting a patch solving both issues


PS: I am not subscribed to the list so please keep me CC'ed

--- hugeadm.c   2013-10-21 21:07:56.000000000 -0400
+++ hugeadm.c   2014-01-23 22:19:17.614797000 -0500
@@ -557,27 +557,23 @@
 
           /* Check if mtab is a symlink */
           useMtab = (readlink(MOUNTED, &dummy, 1) < 0);
-          if (!useMtab) {
-           /* No need updating mtab */
-              return 0;
-           }
-
-
-               mounts = setmntent(MOUNTED, "a+");
-               if (mounts) {
-                       entry.mnt_fsname = FS_NAME;
-                       entry.mnt_dir = path;
-                       entry.mnt_type = FS_NAME;
-                       entry.mnt_opts = options;
-                       entry.mnt_freq = 0;
-                       entry.mnt_passno = 0;
-                       if (addmntent(mounts, &entry))
-                               WARNING("Unable to add entry %s to %s, error: 
%s\n",
-                                       path, MOUNTED, strerror(errno));
-                       endmntent(mounts);
-               } else {
-                       WARNING("Unable to open %s, error: %s\n",
-                               MOUNTED, strerror(errno));
+          if (useMtab) {
+                       mounts = setmntent(MOUNTED, "a+");
+                       if (mounts) {
+                               entry.mnt_fsname = FS_NAME;
+                               entry.mnt_dir = path;
+                               entry.mnt_type = FS_NAME;
+                               entry.mnt_opts = options;
+                               entry.mnt_freq = 0;
+                               entry.mnt_passno = 0;
+                               if (addmntent(mounts, &entry))
+                                       WARNING("Unable to add entry %s to %s, 
error: %s\n",
+                                               path, MOUNTED, strerror(errno));
+                               endmntent(mounts);
+                       } else {
+                               WARNING("Unable to open %s, error: %s\n",
+                                       MOUNTED, strerror(errno));
+                       }
                }
 
                if (chown(path, uid, gid)) {
@@ -1687,7 +1683,7 @@
 
        if (opt_global_mounts) {
                snprintf(base, PATH_MAX, "%s/global", MOUNT_DIR);
-               create_mounts(NULL, NULL, base, S_IRWXU | S_IRWXG | S_IRWXO);
+               create_mounts(NULL, NULL, base, S_IRWXU | S_IRWXG | S_IRWXO | 
S_ISVTX );
        }
 
        if (opt_pgsizes)


-- 
Guillaume Morin <guilla...@morinfr.org>

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to