Skip to content

Commit

Permalink
Adding the option to select the group by name
Browse files Browse the repository at this point in the history
  • Loading branch information
silverdaz committed Dec 21, 2024
1 parent 1f591cf commit f2e4265
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <ctype.h>
#include <grp.h>

#define OFF_FMT "%lu"
#define INO_FMT "%lu"
Expand Down Expand Up @@ -106,6 +107,7 @@ struct fs_config {

uid_t uid;
gid_t gid;
char* group_name;
time_t mounted_at;
int direct_io;

Expand Down
18 changes: 17 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static void usage(struct fuse_args *args)
" -o dotdot Shows '.' and '..' directories [default: ignored]\n"
" -o user_id=N user id of the mount point [default: caller's uid]\n"
" -o group_id=N group id of the mount point [default: caller's gid]\n"
" -o group_name=S group name of the mount point [overwrites group_id]\n"
"\n"
"Crypt4GH Options (if enabled):\n"
" -o seckey=<path> Absolute path to the Crypt4GH secret key\n"
Expand Down Expand Up @@ -76,6 +77,7 @@ static struct fuse_opt fs_opts[] = {
/* Mount group id */
CRYPT4GH_SQLITE_OPT("user_id=%u", uid, 0), // chill... it's not root
CRYPT4GH_SQLITE_OPT("group_id=%u", gid, 0),
CRYPT4GH_SQLITE_OPT("group_name=%s", group_name, 0),

/* in case Crypt4GH is enabled */
CRYPT4GH_SQLITE_OPT("seckey=%s" , seckeypath , 0),
Expand Down Expand Up @@ -140,7 +142,6 @@ fs_opt_proc(void *data, const char *arg, int key, struct fuse_args *outargs)
}
}


static int
read_passphrase(const char* prompt)
{
Expand Down Expand Up @@ -335,6 +336,21 @@ int main(int argc, char *argv[])
exit(1);
}

if ( config.group_name )
{
//errno = 0;
struct group *gr = getgrnam(config.group_name);
if (gr == NULL){
//if( errno != 0){
fprintf(stderr, "Invalid group name: %s\n", strerror(errno));
fprintf(stderr, "see `%s -h' for usage\n", argv[0]);
exit(1);
//}
} else {
config.gid = gr->gr_gid;
}
}

/* File and Dir permissions */
mode_t mask = umask(0);
umask(mask); /* restore */
Expand Down

0 comments on commit f2e4265

Please sign in to comment.