int main(int argc, char *argv[]) { int i; int fuse_stat; struct bb_state *bb_data; if ((getuid() == 0) || (geteuid() == 0)) { fprintf(stderr, "Running BBFS as root opens unnacceptable security holes\n"); return 1; } bb_data = calloc(sizeof(struct bb_state), 1); if (bb_data == NULL) { perror("main calloc"); abort(); } bb_data->logfile = log_open(); for (i = 1; (i < argc) && (argv[i][0] == '-'); i++) if (argv[i][1] == 'o') i++; if ((argc - i) != 2) bb_usage(); bb_data->rootdir = realpath(argv[i], NULL); argv[i] = argv[i+1]; argc--; fprintf(stderr, "initializing filesystem...\n"); fuse_stat = fuse_main(argc, argv, &bb_oper, bb_data); fprintf(stderr, "return value of fuse_main = %d\n", fuse_stat); return fuse_stat; }
/* argv should be as follows: argv[0] = the command bbfs argv[argc-3] = the root directory argv[argc-2] = the mount point argv[argc-1] = uid */ int main(int argc, char *argv[]) { int fuse_stat; struct bb_state *bb_data; char* arg_uid = argv[argc-1]; // bbfs doesn't do any access checking on its own (the comment // blocks in fuse.h mention some of the functions that need // accesses checked -- but note there are other functions, like // chown(), that also need checking!). Since running bbfs as root // will therefore open Metrodome-sized holes in the system // security, we'll check if root is trying to mount the filesystem // and refuse if it is. The somewhat smaller hole of an ordinary // user doing it with the allow_other flag is still there because // I don't want to parse the options string. if ((getuid() == 0) || (geteuid() == 0)) { fprintf(stderr, "Running BBFS as root opens unnacceptable security holes\n"); return 1; } // Perform some sanity checking on the command line: make sure // there are enough arguments, and that neither of the last two // start with a hyphen (this will break if you actually have a // rootpoint or mountpoint whose name starts with a hyphen, but so // will a zillion other programs) if ((argc < 4) || (argv[argc-3][0] == '-') || (argv[argc-2][0] == '-')) bb_usage(); bb_data = malloc(sizeof(struct bb_state)); if (bb_data == NULL) { perror("main calloc"); abort(); } // UID set in bb_data as arguement 3 inputed bb_data->uid = atoi(arg_uid); // Pull the rootdir out of the argument list and save it in // bb_data->rootdir bb_data->rootdir = realpath(argv[argc-3], NULL); argv[argc-3] = argv[argc-2]; argv[argc-2] = NULL; argc-= 2; // open the log file and save its handle bb_data->logfile = log_open(); // turn over control to fuse fprintf(stderr, "about to call fuse_main\n"); /* bb_oper - the struct fuse_operations we constructed bb_data - bb_state where bb_state holds just the logfile and rootdir invokes the init function */ fuse_stat = fuse_main(argc, argv, &bb_oper, bb_data); fprintf(stderr, "fuse_main returned %d\n", fuse_stat); return fuse_stat; }
int main(int argc, char *argv[]) { int i; int fuse_stat; struct bb_state *bb_data; // bbfs doesn't do any access checking on its own (the comment // blocks in fuse.h mention some of the functions that need // accesses checked -- but note there are other functions, like // chown(), that also need checking!). Since running bbfs as root // will therefore open Metrodome-sized holes in the system // security, we'll check if root is trying to mount the filesystem // and refuse if it is. The somewhat smaller hole of an ordinary // user doing it with the allow_other flag is still there because // I don't want to parse the options string. if ((getuid() == 0) || (geteuid() == 0)) { fprintf(stderr, "Running BBFS as root opens unnacceptable security holes\n"); return 1; } bb_data = calloc(sizeof(struct bb_state), 1); if (bb_data == NULL) { perror("main calloc"); abort(); } bb_data->logfile = log_open(); // libfuse is able to do most of the command line parsing; all I // need to do is to extract the rootdir; this will be the first // non-option passed in. I'm using the GNU non-standard extension // and having realpath malloc the space for the path // the string. for (i = 1; (i < argc) && (argv[i][0] == '-'); i++) if (argv[i][1] == 'o') i++; // -o takes a parameter; need to // skip it too. This doesn't // handle "squashed" parameters if ((argc - i) != 2) bb_usage(); bb_data->rootdir = realpath(argv[i], NULL); argv[i] = argv[i+1]; argc--; fprintf(stderr, "about to call fuse_main\n"); fuse_stat = fuse_main(argc, argv, &bb_oper, bb_data); fprintf(stderr, "fuse_main returned %d\n", fuse_stat); return fuse_stat; }
int main(int argc, char *argv[]) { int fuse_stat; struct bb_state *bb_data; /* set the encryption key */ AES_set_encrypt_key (ckey, 128, &key); // bbfs doesn't do any access checking on its own (the comment // blocks in fuse.h mention some of the functions that need // accesses checked -- but note there are other functions, like // chown(), that also need checking!). Since running bbfs as root // will therefore open Metrodome-sized holes in the system // security, we'll check if root is trying to mount the filesystem // and refuse if it is. The somewhat smaller hole of an ordinary // user doing it with the allow_other flag is still there because // I don't want to parse the options string. if ((getuid() == 0) || (geteuid() == 0)) { fprintf(stderr, "Running BBFS as root opens unnacceptable security holes\n"); return 1; } // See which version of fuse we're running fprintf(stderr, "Fuse library version %d.%d\n", FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION); // Perform some sanity checking on the command line: make sure // there are enough arguments, and that neither of the last two // start with a hyphen (this will break if you actually have a // rootpoint or mountpoint whose name starts with a hyphen, but so // will a zillion other programs) if ((argc < 4) || (argv[argc-2][0] == '-') || (argv[argc-1][0] == '-')) bb_usage(); bb_data = malloc(sizeof(struct bb_state)); if (bb_data == NULL) { perror("main calloc"); abort(); } if(argc ==4 ) { encryption = atoi(argv[3]); argc--; } // Pull the rootdir out of the argument list and save it in my // internal data bb_data->rootdir = realpath(argv[argc-2], NULL); argv[argc-2] = argv[argc-1]; argv[argc-1] = NULL; argc--; bb_data->logfile = log_open(); // turn over control to fuse fprintf(stderr, "about to call fuse_main\n"); fuse_stat = fuse_main(argc, argv, &bb_oper, bb_data); fprintf(stderr, "fuse_main returned %d\n", fuse_stat); return fuse_stat; }