-
Notifications
You must be signed in to change notification settings - Fork 1.3k
libmount: non-root mkdir support #3640
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Karel Zak <[email protected]>
* introduce do_canonicalize() with proper return values * use do_canonicalize() everywhere Signed-off-by: Karel Zak <[email protected]>
Signed-off-by: Karel Zak <[email protected]>
* add ul_restricted_path_oper() to fileutils.c * use it as backed for canonicalize_path_restricted() Signed-off-by: Karel Zak <[email protected]>
Signed-off-by: Karel Zak <[email protected]>
Based on ul_restricted_path_oper(). Signed-off-by: Karel Zak <[email protected]>
Signed-off-by: Karel Zak <[email protected]>
Signed-off-by: Karel Zak <[email protected]>
Based-on: util-linux#3597 Signed-off-by: Karel Zak <[email protected]>
fb3655d
to
02f6eb5
Compare
Signed-off-by: Karel Zak <[email protected]>
Signed-off-by: Karel Zak <[email protected]>
Signed-off-by: Karel Zak <[email protected]>
Signed-off-by: Karel Zak <[email protected]>
Signed-off-by: Karel Zak <[email protected]>
* test classic user-mount (mount.static required) * test user-mount with X-mount.mkdir Signed-off-by: Karel Zak <[email protected]>
lib/canonicalize.c
Outdated
len = canonical ? (ssize_t) strlen(canonical) : | ||
errno ? -errno : -EINVAL; | ||
len = canonical ?(ssize_t) strlen(canonical) : | ||
errno ? -errno : -EINVAL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spurious whitespace changes? If intentional should be in a dedicated commit.
if (!path || !*path) | ||
return NULL; | ||
if (result) | ||
*result = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result
seems to be always non-NULL.
|
||
errno = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems unnecessary.
* unreachable path is not an error (!), and in this case, it just duplicates | ||
* @path. | ||
*/ | ||
char *canonicalize_path(const char *path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these also all get the ul_
prefix?
fprintf(stdout, "real: %s\n", canonicalize_path(argv[1])); | ||
|
||
fprintf(stdout, "real: %s\n", canonicalize_path(argv[1])); | ||
fprintf(stdout, "real-restricted: %s\n", canonicalize_path_restricted(argv[1])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be used to have a real unittest which validates the results?
ts_init_subtest "basic" | ||
TS_FSTAB="/etc/fstab" | ||
ts_fstab_add $MOUNT_SOURCE $MOUNT_TARGET "none" "bind,user,default,noauto" | ||
runuser -u testuser_mount -- $TS_CMD_MOUNT_STATIC $MOUNT_TARGET >> $TS_OUTPUT 2>> $TS_ERRLOG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use the runuser
from the current build.
|
||
# Add test user | ||
# | ||
useradd -u 9899 --shell /bin/bash testuser_mount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of this. Can we use nobody
?
Or just a random user id from a transient uid range.
# classic user-mount | ||
# | ||
ts_init_subtest "basic" | ||
TS_FSTAB="/etc/fstab" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the regular test fstab not enough?
runuser -u testuser_mount -- $TS_CMD_MOUNT_STATIC $MOUNT_TARGET >> $TS_OUTPUT 2>> $TS_ERRLOG | ||
opts=$(findmnt -nr -o VFS-OPTIONS --mountpoint $MOUNT_TARGET) | ||
[[ $opts == *"noexec"* && $opts == *"nosuid"* && $opts == *"nodev"* ]] \ | ||
|| ts_log "Cannot find user options" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ts_errlog
TS_FSTAB="/etc/fstab" | ||
ts_fstab_add $MOUNT_SOURCE $MOUNT_TARGET "none" "bind,user,default,noauto" | ||
runuser -u testuser_mount -- $TS_CMD_MOUNT_STATIC $MOUNT_TARGET >> $TS_OUTPUT 2>> $TS_ERRLOG | ||
opts=$(findmnt -nr -o VFS-OPTIONS --mountpoint $MOUNT_TARGET) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TS_CMD_FINDMNT
I'll split this pull request into three separate pull requests:
I'll keep it open as a draw until all is implemented. |
No description provided.