diff mbox

[v4,7/7] genhomedircon: fix FALLBACK_NAME regex

Message ID 1462003092-4611-8-git-send-email-jason@perfinion.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Jason Zaman April 30, 2016, 7:58 a.m. UTC
Originally the fallback regex for the username was either ".*" or
"[^/]*". The second is more correct but still can match nothing.
changing the * to + means that it must match at least one character.

Signed-off-by: Jason Zaman <jason@perfinion.com>
---
 libsemanage/src/genhomedircon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stephen Smalley May 2, 2016, 12:46 p.m. UTC | #1
On 04/30/2016 03:58 AM, Jason Zaman wrote:
> Originally the fallback regex for the username was either ".*" or
> "[^/]*". The second is more correct but still can match nothing.
> changing the * to + means that it must match at least one character.
> 
> Signed-off-by: Jason Zaman <jason@perfinion.com>

Thanks, applied the entire series.

> ---
>  libsemanage/src/genhomedircon.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libsemanage/src/genhomedircon.c b/libsemanage/src/genhomedircon.c
> index 6c6eaef..c5ea436 100644
> --- a/libsemanage/src/genhomedircon.c
> +++ b/libsemanage/src/genhomedircon.c
> @@ -86,7 +86,7 @@
>  #define FALLBACK_SENAME "user_u"
>  #define FALLBACK_PREFIX "user"
>  #define FALLBACK_LEVEL "s0"
> -#define FALLBACK_NAME ".*"
> +#define FALLBACK_NAME "[^/]+"
>  #define FALLBACK_UIDGID "[0-9]+"
>  #define DEFAULT_LOGIN "__default__"
>  
> @@ -1024,7 +1024,7 @@ static int write_context_file(genhomedircon_settings_t * s, FILE * out)
>  		for (h = homedirs; h; h = h->next) {
>  			Ustr *temp = ustr_dup_cstr(h->data);
>  
> -			if (!temp || !ustr_add_cstr(&temp, "/[^/]*")) {
> +			if (!temp || !ustr_add_cstr(&temp, "/" FALLBACK_NAME)) {
>  				ustr_sc_free(&temp);
>  				retval = STATUS_ERR;
>  				goto done;
>
diff mbox

Patch

diff --git a/libsemanage/src/genhomedircon.c b/libsemanage/src/genhomedircon.c
index 6c6eaef..c5ea436 100644
--- a/libsemanage/src/genhomedircon.c
+++ b/libsemanage/src/genhomedircon.c
@@ -86,7 +86,7 @@ 
 #define FALLBACK_SENAME "user_u"
 #define FALLBACK_PREFIX "user"
 #define FALLBACK_LEVEL "s0"
-#define FALLBACK_NAME ".*"
+#define FALLBACK_NAME "[^/]+"
 #define FALLBACK_UIDGID "[0-9]+"
 #define DEFAULT_LOGIN "__default__"
 
@@ -1024,7 +1024,7 @@  static int write_context_file(genhomedircon_settings_t * s, FILE * out)
 		for (h = homedirs; h; h = h->next) {
 			Ustr *temp = ustr_dup_cstr(h->data);
 
-			if (!temp || !ustr_add_cstr(&temp, "/[^/]*")) {
+			if (!temp || !ustr_add_cstr(&temp, "/" FALLBACK_NAME)) {
 				ustr_sc_free(&temp);
 				retval = STATUS_ERR;
 				goto done;