|
|
753371 |
diff --git libsemanage-2.8/src/direct_api.c libsemanage-2.8/src/direct_api.c
|
|
|
753371 |
index c58961b..8e4d116 100644
|
|
|
753371 |
--- libsemanage-2.8/src/direct_api.c
|
|
|
753371 |
+++ libsemanage-2.8/src/direct_api.c
|
|
|
753371 |
@@ -1028,7 +1028,7 @@ static int semanage_direct_write_langext(semanage_handle_t *sh,
|
|
|
753371 |
|
|
|
753371 |
fp = NULL;
|
|
|
753371 |
|
|
|
753371 |
- ret = 0;
|
|
|
753371 |
+ return 0;
|
|
|
753371 |
|
|
|
753371 |
cleanup:
|
|
|
753371 |
if (fp != NULL) fclose(fp);
|
|
|
753371 |
@@ -2177,7 +2177,6 @@ cleanup:
|
|
|
753371 |
semanage_module_info_destroy(sh, modinfo);
|
|
|
753371 |
free(modinfo);
|
|
|
753371 |
|
|
|
753371 |
- if (fp != NULL) fclose(fp);
|
|
|
753371 |
return status;
|
|
|
753371 |
}
|
|
|
753371 |
|
|
|
753371 |
@@ -2342,16 +2341,6 @@ static int semanage_direct_get_module_info(semanage_handle_t *sh,
|
|
|
753371 |
free(tmp);
|
|
|
753371 |
tmp = NULL;
|
|
|
753371 |
|
|
|
753371 |
- if (fclose(fp) != 0) {
|
|
|
753371 |
- ERR(sh,
|
|
|
753371 |
- "Unable to close %s module lang ext file.",
|
|
|
753371 |
- (*modinfo)->name);
|
|
|
753371 |
- status = -1;
|
|
|
753371 |
- goto cleanup;
|
|
|
753371 |
- }
|
|
|
753371 |
-
|
|
|
753371 |
- fp = NULL;
|
|
|
753371 |
-
|
|
|
753371 |
/* lookup enabled/disabled status */
|
|
|
753371 |
ret = semanage_module_get_path(sh,
|
|
|
753371 |
*modinfo,
|
|
|
753371 |
@@ -2395,7 +2384,13 @@ cleanup:
|
|
|
753371 |
free(modinfos);
|
|
|
753371 |
}
|
|
|
753371 |
|
|
|
753371 |
- if (fp != NULL) fclose(fp);
|
|
|
753371 |
+ if (fp != NULL && fclose(fp) != 0) {
|
|
|
753371 |
+ ERR(sh,
|
|
|
753371 |
+ "Unable to close %s module lang ext file.",
|
|
|
753371 |
+ (*modinfo)->name);
|
|
|
753371 |
+ status = -1;
|
|
|
753371 |
+ }
|
|
|
753371 |
+
|
|
|
753371 |
return status;
|
|
|
753371 |
}
|
|
|
753371 |
|
|
|
753371 |
diff --git libsemanage-2.8/src/genhomedircon.c libsemanage-2.8/src/genhomedircon.c
|
|
|
753371 |
index 3e61b51..c35f878 100644
|
|
|
753371 |
--- libsemanage-2.8/src/genhomedircon.c
|
|
|
753371 |
+++ libsemanage-2.8/src/genhomedircon.c
|
|
|
753371 |
@@ -1074,10 +1074,20 @@ static int get_group_users(genhomedircon_settings_t * s,
|
|
|
753371 |
|
|
|
753371 |
const char *grname = selogin + 1;
|
|
|
753371 |
|
|
|
753371 |
- if (getgrnam_r(grname, &grstorage, grbuf,
|
|
|
753371 |
- (size_t) grbuflen, &group) != 0) {
|
|
|
753371 |
- goto cleanup;
|
|
|
753371 |
+ errno = 0;
|
|
|
753371 |
+ while (
|
|
|
753371 |
+ (retval = getgrnam_r(grname, &grstorage, grbuf, (size_t) grbuflen, &group)) != 0 &&
|
|
|
753371 |
+ errno == ERANGE
|
|
|
753371 |
+ ) {
|
|
|
753371 |
+ char *new_grbuf;
|
|
|
753371 |
+ grbuflen *= 2;
|
|
|
753371 |
+ new_grbuf = realloc(grbuf, grbuflen);
|
|
|
753371 |
+ if (new_grbuf == NULL)
|
|
|
753371 |
+ goto cleanup;
|
|
|
753371 |
+ grbuf = new_grbuf;
|
|
|
753371 |
}
|
|
|
753371 |
+ if (retval == -1)
|
|
|
753371 |
+ goto cleanup;
|
|
|
753371 |
|
|
|
753371 |
if (group == NULL) {
|
|
|
753371 |
ERR(s->h_semanage, "Can't find group named %s\n", grname);
|
|
|
753371 |
diff --git libsemanage-2.8/src/semanage_store.c libsemanage-2.8/src/semanage_store.c
|
|
|
753371 |
index f1984c5..58dded6 100644
|
|
|
753371 |
--- libsemanage-2.8/src/semanage_store.c
|
|
|
753371 |
+++ libsemanage-2.8/src/semanage_store.c
|
|
|
753371 |
@@ -541,14 +541,18 @@ int semanage_create_store(semanage_handle_t * sh, int create)
|
|
|
753371 |
struct stat sb;
|
|
|
753371 |
const char *path = semanage_files[SEMANAGE_ROOT];
|
|
|
753371 |
int fd;
|
|
|
753371 |
+ mode_t mask;
|
|
|
753371 |
|
|
|
753371 |
if (stat(path, &sb) == -1) {
|
|
|
753371 |
if (errno == ENOENT && create) {
|
|
|
753371 |
+ mask = umask(0077);
|
|
|
753371 |
if (mkdir(path, S_IRWXU) == -1) {
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
ERR(sh, "Could not create module store at %s.",
|
|
|
753371 |
path);
|
|
|
753371 |
return -2;
|
|
|
753371 |
}
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
} else {
|
|
|
753371 |
if (create)
|
|
|
753371 |
ERR(sh,
|
|
|
753371 |
@@ -567,12 +571,15 @@ int semanage_create_store(semanage_handle_t * sh, int create)
|
|
|
753371 |
path = semanage_path(SEMANAGE_ACTIVE, SEMANAGE_TOPLEVEL);
|
|
|
753371 |
if (stat(path, &sb) == -1) {
|
|
|
753371 |
if (errno == ENOENT && create) {
|
|
|
753371 |
+ mask = umask(0077);
|
|
|
753371 |
if (mkdir(path, S_IRWXU) == -1) {
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
ERR(sh,
|
|
|
753371 |
"Could not create module store, active subdirectory at %s.",
|
|
|
753371 |
path);
|
|
|
753371 |
return -2;
|
|
|
753371 |
}
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
} else {
|
|
|
753371 |
ERR(sh,
|
|
|
753371 |
"Could not read from module store, active subdirectory at %s.",
|
|
|
753371 |
@@ -590,12 +597,15 @@ int semanage_create_store(semanage_handle_t * sh, int create)
|
|
|
753371 |
path = semanage_path(SEMANAGE_ACTIVE, SEMANAGE_MODULES);
|
|
|
753371 |
if (stat(path, &sb) == -1) {
|
|
|
753371 |
if (errno == ENOENT && create) {
|
|
|
753371 |
+ mask = umask(0077);
|
|
|
753371 |
if (mkdir(path, S_IRWXU) == -1) {
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
ERR(sh,
|
|
|
753371 |
"Could not create module store, active modules subdirectory at %s.",
|
|
|
753371 |
path);
|
|
|
753371 |
return -2;
|
|
|
753371 |
}
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
} else {
|
|
|
753371 |
ERR(sh,
|
|
|
753371 |
"Could not read from module store, active modules subdirectory at %s.",
|
|
|
753371 |
@@ -613,11 +623,14 @@ int semanage_create_store(semanage_handle_t * sh, int create)
|
|
|
753371 |
path = semanage_files[SEMANAGE_READ_LOCK];
|
|
|
753371 |
if (stat(path, &sb) == -1) {
|
|
|
753371 |
if (errno == ENOENT && create) {
|
|
|
753371 |
+ mask = umask(0077);
|
|
|
753371 |
if ((fd = creat(path, S_IRUSR | S_IWUSR)) == -1) {
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
ERR(sh, "Could not create lock file at %s.",
|
|
|
753371 |
path);
|
|
|
753371 |
return -2;
|
|
|
753371 |
}
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
close(fd);
|
|
|
753371 |
} else {
|
|
|
753371 |
ERR(sh, "Could not read lock file at %s.", path);
|
|
|
753371 |
@@ -763,6 +776,7 @@ static int semanage_copy_dir_flags(const char *src, const char *dst, int flag)
|
|
|
753371 |
struct stat sb;
|
|
|
753371 |
struct dirent **names = NULL;
|
|
|
753371 |
char path[PATH_MAX], path2[PATH_MAX];
|
|
|
753371 |
+ mode_t mask;
|
|
|
753371 |
|
|
|
753371 |
if ((len = scandir(src, &names, semanage_filename_select, NULL)) == -1) {
|
|
|
753371 |
fprintf(stderr, "Could not read the contents of %s: %s\n", src, strerror(errno));
|
|
|
753371 |
@@ -770,10 +784,13 @@ static int semanage_copy_dir_flags(const char *src, const char *dst, int flag)
|
|
|
753371 |
}
|
|
|
753371 |
|
|
|
753371 |
if (stat(dst, &sb) != 0) {
|
|
|
753371 |
+ mask = umask(0077);
|
|
|
753371 |
if (mkdir(dst, S_IRWXU) != 0) {
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
fprintf(stderr, "Could not create %s: %s\n", dst, strerror(errno));
|
|
|
753371 |
goto cleanup;
|
|
|
753371 |
}
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
}
|
|
|
753371 |
|
|
|
753371 |
for (i = 0; i < len; i++) {
|
|
|
753371 |
@@ -785,14 +802,20 @@ static int semanage_copy_dir_flags(const char *src, const char *dst, int flag)
|
|
|
753371 |
}
|
|
|
753371 |
snprintf(path2, sizeof(path2), "%s/%s", dst, names[i]->d_name);
|
|
|
753371 |
if (S_ISDIR(sb.st_mode)) {
|
|
|
753371 |
+ mask = umask(0077);
|
|
|
753371 |
if (mkdir(path2, 0700) == -1 ||
|
|
|
753371 |
semanage_copy_dir_flags(path, path2, flag) == -1) {
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
goto cleanup;
|
|
|
753371 |
}
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
} else if (S_ISREG(sb.st_mode) && flag == 1) {
|
|
|
753371 |
+ mask = umask(0077);
|
|
|
753371 |
if (semanage_copy_file(path, path2, sb.st_mode) < 0) {
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
goto cleanup;
|
|
|
753371 |
}
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
}
|
|
|
753371 |
}
|
|
|
753371 |
retval = 0;
|
|
|
753371 |
@@ -872,16 +895,20 @@ int semanage_mkdir(semanage_handle_t *sh, const char *path)
|
|
|
753371 |
{
|
|
|
753371 |
int status = 0;
|
|
|
753371 |
struct stat sb;
|
|
|
753371 |
+ mode_t mask;
|
|
|
753371 |
|
|
|
753371 |
/* check if directory already exists */
|
|
|
753371 |
if (stat(path, &sb) != 0) {
|
|
|
753371 |
/* make the modules directory */
|
|
|
753371 |
+ mask = umask(0077);
|
|
|
753371 |
if (mkdir(path, S_IRWXU) != 0) {
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
ERR(sh, "Cannot make directory at %s", path);
|
|
|
753371 |
status = -1;
|
|
|
753371 |
goto cleanup;
|
|
|
753371 |
|
|
|
753371 |
}
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
}
|
|
|
753371 |
else {
|
|
|
753371 |
/* check that it really is a directory */
|
|
|
753371 |
@@ -906,6 +933,7 @@ int semanage_make_sandbox(semanage_handle_t * sh)
|
|
|
753371 |
const char *sandbox = semanage_path(SEMANAGE_TMP, SEMANAGE_TOPLEVEL);
|
|
|
753371 |
struct stat buf;
|
|
|
753371 |
int errsv;
|
|
|
753371 |
+ mode_t mask;
|
|
|
753371 |
|
|
|
753371 |
if (stat(sandbox, &buf) == -1) {
|
|
|
753371 |
if (errno != ENOENT) {
|
|
|
753371 |
@@ -922,12 +950,15 @@ int semanage_make_sandbox(semanage_handle_t * sh)
|
|
|
753371 |
}
|
|
|
753371 |
}
|
|
|
753371 |
|
|
|
753371 |
+ mask = umask(0077);
|
|
|
753371 |
if (mkdir(sandbox, S_IRWXU) == -1 ||
|
|
|
753371 |
semanage_copy_dir(semanage_path(SEMANAGE_ACTIVE, SEMANAGE_TOPLEVEL),
|
|
|
753371 |
sandbox) == -1) {
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
ERR(sh, "Could not copy files to sandbox %s.", sandbox);
|
|
|
753371 |
goto cleanup;
|
|
|
753371 |
}
|
|
|
753371 |
+ umask(mask);
|
|
|
753371 |
return 0;
|
|
|
753371 |
|
|
|
753371 |
cleanup:
|
|
|
753371 |
diff --git libsemanage-2.8/src/seusers_local.c libsemanage-2.8/src/seusers_local.c
|
|
|
753371 |
index 413ebdd..a79e2d3 100644
|
|
|
753371 |
--- libsemanage-2.8/src/seusers_local.c
|
|
|
753371 |
+++ libsemanage-2.8/src/seusers_local.c
|
|
|
753371 |
@@ -71,17 +71,18 @@ static int semanage_seuser_audit(semanage_handle_t * handle,
|
|
|
753371 |
const char *sep = "-";
|
|
|
753371 |
int rc = -1;
|
|
|
753371 |
strcpy(msg, "login");
|
|
|
753371 |
+ if (previous) {
|
|
|
753371 |
+ name = semanage_seuser_get_name(previous);
|
|
|
753371 |
+ psename = semanage_seuser_get_sename(previous);
|
|
|
753371 |
+ pmls = semanage_seuser_get_mlsrange(previous);
|
|
|
753371 |
+ proles = semanage_user_roles(handle, psename);
|
|
|
753371 |
+ }
|
|
|
753371 |
if (seuser) {
|
|
|
753371 |
name = semanage_seuser_get_name(seuser);
|
|
|
753371 |
sename = semanage_seuser_get_sename(seuser);
|
|
|
753371 |
mls = semanage_seuser_get_mlsrange(seuser);
|
|
|
753371 |
roles = semanage_user_roles(handle, sename);
|
|
|
753371 |
}
|
|
|
753371 |
- if (previous) {
|
|
|
753371 |
- psename = semanage_seuser_get_sename(previous);
|
|
|
753371 |
- pmls = semanage_seuser_get_mlsrange(previous);
|
|
|
753371 |
- proles = semanage_user_roles(handle, psename);
|
|
|
753371 |
- }
|
|
|
753371 |
if (audit_type != AUDIT_ROLE_REMOVE) {
|
|
|
753371 |
if (sename && (!psename || strcmp(psename, sename) != 0)) {
|
|
|
753371 |
strcat(msg,sep);
|