diff options
Diffstat (limited to 'src/firejail/util.c')
-rw-r--r-- | src/firejail/util.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/firejail/util.c b/src/firejail/util.c index 54f83dccf..acbc19234 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c | |||
@@ -118,7 +118,7 @@ int mkpath_as_root(const char* path) { | |||
118 | void fwarning(char* fmt, ...) { | 118 | void fwarning(char* fmt, ...) { |
119 | if (arg_quiet) | 119 | if (arg_quiet) |
120 | return; | 120 | return; |
121 | 121 | ||
122 | va_list args; | 122 | va_list args; |
123 | va_start(args,fmt); | 123 | va_start(args,fmt); |
124 | fprintf(stderr, "Warning: "); | 124 | fprintf(stderr, "Warning: "); |
@@ -786,7 +786,7 @@ static int remove_callback(const char *fpath, const struct stat *sb, int typefla | |||
786 | (void) sb; | 786 | (void) sb; |
787 | (void) typeflag; | 787 | (void) typeflag; |
788 | (void) ftwbuf; | 788 | (void) ftwbuf; |
789 | 789 | ||
790 | int rv = remove(fpath); | 790 | int rv = remove(fpath); |
791 | if (rv) | 791 | if (rv) |
792 | perror(fpath); | 792 | perror(fpath); |
@@ -816,7 +816,7 @@ void create_empty_dir_as_root(const char *dir, mode_t mode) { | |||
816 | assert(dir); | 816 | assert(dir); |
817 | mode &= 07777; | 817 | mode &= 07777; |
818 | struct stat s; | 818 | struct stat s; |
819 | 819 | ||
820 | if (stat(dir, &s)) { | 820 | if (stat(dir, &s)) { |
821 | if (arg_debug) | 821 | if (arg_debug) |
822 | printf("Creating empty %s directory\n", dir); | 822 | printf("Creating empty %s directory\n", dir); |
@@ -862,7 +862,7 @@ int set_perms(const char *fname, uid_t uid, gid_t gid, mode_t mode) { | |||
862 | void mkdir_attr(const char *fname, mode_t mode, uid_t uid, gid_t gid) { | 862 | void mkdir_attr(const char *fname, mode_t mode, uid_t uid, gid_t gid) { |
863 | assert(fname); | 863 | assert(fname); |
864 | mode &= 07777; | 864 | mode &= 07777; |
865 | #if 0 | 865 | #if 0 |
866 | printf("fname %s, uid %d, gid %d, mode %x - ", fname, uid, gid, (unsigned) mode); | 866 | printf("fname %s, uid %d, gid %d, mode %x - ", fname, uid, gid, (unsigned) mode); |
867 | if (S_ISLNK(mode)) | 867 | if (S_ISLNK(mode)) |
868 | printf("l"); | 868 | printf("l"); |
@@ -886,7 +886,7 @@ void mkdir_attr(const char *fname, mode_t mode, uid_t uid, gid_t gid) { | |||
886 | printf( (mode & S_IWOTH) ? "w" : "-"); | 886 | printf( (mode & S_IWOTH) ? "w" : "-"); |
887 | printf( (mode & S_IXOTH) ? "x" : "-"); | 887 | printf( (mode & S_IXOTH) ? "x" : "-"); |
888 | printf("\n"); | 888 | printf("\n"); |
889 | #endif | 889 | #endif |
890 | if (mkdir(fname, mode) == -1 || | 890 | if (mkdir(fname, mode) == -1 || |
891 | chmod(fname, mode) == -1 || | 891 | chmod(fname, mode) == -1 || |
892 | chown(fname, uid, gid)) { | 892 | chown(fname, uid, gid)) { |
@@ -899,7 +899,7 @@ void mkdir_attr(const char *fname, mode_t mode, uid_t uid, gid_t gid) { | |||
899 | 899 | ||
900 | char *read_text_file_or_exit(const char *fname) { | 900 | char *read_text_file_or_exit(const char *fname) { |
901 | assert(fname); | 901 | assert(fname); |
902 | 902 | ||
903 | // open file | 903 | // open file |
904 | int fd = open(fname, O_RDONLY); | 904 | int fd = open(fname, O_RDONLY); |
905 | if (fd == -1) { | 905 | if (fd == -1) { |
@@ -912,7 +912,7 @@ char *read_text_file_or_exit(const char *fname) { | |||
912 | goto errexit; | 912 | goto errexit; |
913 | if (lseek(fd, 0 , SEEK_SET) == -1) | 913 | if (lseek(fd, 0 , SEEK_SET) == -1) |
914 | goto errexit; | 914 | goto errexit; |
915 | 915 | ||
916 | // allocate memory | 916 | // allocate memory |
917 | char *data = malloc(size + 1); // + '\0' | 917 | char *data = malloc(size + 1); // + '\0' |
918 | if (data == NULL) | 918 | if (data == NULL) |
@@ -928,11 +928,11 @@ char *read_text_file_or_exit(const char *fname) { | |||
928 | } | 928 | } |
929 | rd += rv; | 929 | rd += rv; |
930 | } | 930 | } |
931 | 931 | ||
932 | // close file | 932 | // close file |
933 | close(fd); | 933 | close(fd); |
934 | return data; | 934 | return data; |
935 | 935 | ||
936 | errexit: | 936 | errexit: |
937 | close(fd); | 937 | close(fd); |
938 | fprintf(stderr, "Error: cannot read %s\n", fname); | 938 | fprintf(stderr, "Error: cannot read %s\n", fname); |