|
From: <ssm...@us...> - 2007-12-05 19:01:43
|
Revision: 2693
http://selinux.svn.sourceforge.net/selinux/?rev=2693&view=rev
Author: ssmalley
Date: 2007-12-05 09:39:30 -0800 (Wed, 05 Dec 2007)
Log Message:
-----------
Author: Daniel J Walsh
Email: dw...@re...
Subject: libsemanage patch
Date: Mon, 03 Dec 2007 15:49:44 -0500
genhomedircon includes the "\n" in /etc/shells so no shells in the
/etc/passwd match.
Rawhide Policy includes policy without a user_context_tpl
swig causes a doublefree if I don't allocate memory when specifying a
alternate store.
>> Isn't this going to cause problems if the last line in /etc/shells has
>> no newline?
>>
>> Instead of:
>> temp[strlen(temp)-1]=0;
>>
>> I would use:
>> temp[strcspn(temp, "\n")] = '\0';
>>
>> That will overwrite the first newline with a NUL or, if there is no
>> newline, the terminating NUL will be overwritten with another NUL, which
>> is harmless. It is a useful idiom...
>
> Given that getline() returns the length read (not to be confused with
> the buffer length), why not just:
> while ((len = getline(&temp, &buff_len, shells)) > 0) {
> if (temp[len-1] == '\n') temp[len-1] = 0;
>
Second try
Modified Paths:
--------------
trunk/libsemanage/src/genhomedircon.c
trunk/libsemanage/src/handle.c
Modified: trunk/libsemanage/src/genhomedircon.c
===================================================================
--- trunk/libsemanage/src/genhomedircon.c 2007-11-29 16:15:26 UTC (rev 2692)
+++ trunk/libsemanage/src/genhomedircon.c 2007-12-05 17:39:30 UTC (rev 2693)
@@ -130,11 +130,13 @@
char *temp = NULL;
semanage_list_t *list = NULL;
size_t buff_len = 0;
+ ssize_t len;
shells = fopen(PATH_SHELLS_FILE, "r");
if (!shells)
return default_shell_list();
- while (getline(&temp, &buff_len, shells) >= 0) {
+ while ((len = getline(&temp, &buff_len, shells)) > 0) {
+ if (temp[len-1] == '\n') temp[len-1] = 0;
if (strcmp(temp, PATH_NOLOGIN_SHELL)) {
if (semanage_list_push(&list, temp)) {
free(temp);
@@ -790,7 +792,7 @@
homedir_context_tpl = make_template(s, &HOME_DIR_PRED);
homeroot_context_tpl = make_template(s, &HOME_ROOT_PRED);
user_context_tpl = make_template(s, &USER_CONTEXT_PRED);
- if (!homedir_context_tpl || !homeroot_context_tpl || !user_context_tpl) {
+ if (!homedir_context_tpl || !homeroot_context_tpl) {
retval = STATUS_ERR;
goto done;
}
@@ -828,16 +830,18 @@
ustr_sc_free(&temp);
}
- if (write_user_context(s, out, user_context_tpl,
- ".*", s->fallback_user,
- s->fallback_user_prefix) != STATUS_SUCCESS) {
- retval = STATUS_ERR;
- goto done;
- }
+ if (user_context_tpl) {
+ if (write_user_context(s, out, user_context_tpl,
+ ".*", s->fallback_user,
+ s->fallback_user_prefix) != STATUS_SUCCESS) {
+ retval = STATUS_ERR;
+ goto done;
+ }
- if (write_gen_home_dir_context(s, out, user_context_tpl,
- homedir_context_tpl) != STATUS_SUCCESS) {
- retval = STATUS_ERR;
+ if (write_gen_home_dir_context(s, out, user_context_tpl,
+ homedir_context_tpl) != STATUS_SUCCESS) {
+ retval = STATUS_ERR;
+ }
}
done:
Modified: trunk/libsemanage/src/handle.c
===================================================================
--- trunk/libsemanage/src/handle.c 2007-11-29 16:15:26 UTC (rev 2692)
+++ trunk/libsemanage/src/handle.c 2007-12-05 17:39:30 UTC (rev 2693)
@@ -27,6 +27,7 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <sys/time.h>
#include "direct_api.h"
@@ -131,7 +132,8 @@
/* This just sets the storename to what the user requests, no
verification of existance will be done until connect */
- sh->conf->store_path = storename;
+ sh->conf->store_path = strdup(storename);
+ assert(sh->conf->store_path); /* no way to return failure */
sh->conf->store_type = storetype;
return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|