summaryrefslogtreecommitdiff
path: root/sbin/mdmfs
diff options
context:
space:
mode:
authorRalf S. Engelschall <rse@FreeBSD.org>2005-10-14 11:21:21 +0000
committerRalf S. Engelschall <rse@FreeBSD.org>2005-10-14 11:21:21 +0000
commitde90a634cba8adb2ba64538ba6d99c72b5794507 (patch)
tree6482fdfe267f5072d7ca11677dc08fc06890fa04 /sbin/mdmfs
parent66e58c20dd1fbb832d78332b91ee9fb4f50a5267 (diff)
downloadsrc-test-de90a634cba8adb2ba64538ba6d99c72b5794507.tar.gz
src-test-de90a634cba8adb2ba64538ba6d99c72b5794507.zip
Fix parsing of mdmfs(8) option "-w <user>:<group>" in case <user> or
<group> is a numeric user/group ID instead of a user/group name (as explicitly intended to be allowed by both the manual page and the implementation). Before this fix, mdmfs(8) aborted: | # mdmfs -s 32m -w 0:0 md /var/tmp/foo | Assertion failed: (mip->mi_have_uid), function extract_ugid, file /usr/src/sbin/mdmfs/mdmfs.c, line 555. | Abort trap (core dumped) The "mi_have_[ug]id" fields were only set in case a name lookup was successful. Instead they also have to be set in case the string to integer conversion was successful. Additionally, as a result of this fix, two assertions at the end of the function are now always true and hence can be just be removed. It is guarrantied that both the UID and the GID are set when the function returns regularily, else it would have been already bailed out with usage()/exit(3) or errx(3) before. Spotted by: Christoph Schug <chris@schug.net> MFC after: 3 days
Notes
Notes: svn path=/head/; revision=151315
Diffstat (limited to 'sbin/mdmfs')
-rw-r--r--sbin/mdmfs/mdmfs.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/sbin/mdmfs/mdmfs.c b/sbin/mdmfs/mdmfs.c
index b855d332bdcdd..4ea4709fb2f02 100644
--- a/sbin/mdmfs/mdmfs.c
+++ b/sbin/mdmfs/mdmfs.c
@@ -497,6 +497,10 @@ do_newfs(const char *args)
*
* In other words, this derives a user and group id from a string
* formatted like the last argument to chown(1).
+ *
+ * Notice: At this point we don't support only a username or only a
+ * group name. do_mtptsetup already does, so when this feature is
+ * desired, this is the only routine that needs to be changed.
*/
static void
extract_ugid(const char *str, struct mtpt_info *mip)
@@ -530,8 +534,8 @@ extract_ugid(const char *str, struct mtpt_info *mip)
if (pw == NULL)
errx(1, "invalid user: %s", user);
*uid = pw->pw_uid;
- mip->mi_have_uid = true;
}
+ mip->mi_have_uid = true;
/* Derive gid. */
*gid = strtoul(group, &p, 10);
@@ -542,18 +546,10 @@ extract_ugid(const char *str, struct mtpt_info *mip)
if (gr == NULL)
errx(1, "invalid group: %s", group);
*gid = gr->gr_gid;
- mip->mi_have_gid = true;
}
+ mip->mi_have_gid = true;
free(ug);
- /*
- * At this point we don't support only a username or only a
- * group name. do_mtptsetup already does, so when this
- * feature is desired, this is the only routine that needs to
- * be changed.
- */
- assert(mip->mi_have_uid);
- assert(mip->mi_have_gid);
}
/*