diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2010-08-14 13:16:11 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2010-08-14 13:16:11 +0000 |
commit | 7c9b2350ebc0e2eaeed94b21534c5835ddabd93c (patch) | |
tree | a0f790ccb4e90f09d7891ebdace59f653cba9e15 /common | |
parent | 6c316619e722c007a65c5ee51dc53df6b33d3e11 (diff) |
also don't expand variables in rest of ${var:+rest} expressions if var is not set or empty
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1169 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'common')
-rw-r--r-- | common/expr.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/common/expr.c b/common/expr.c index 4f957ee..36f3f3d 100644 --- a/common/expr.c +++ b/common/expr.c @@ -124,10 +124,19 @@ MUST_USE static const char *parse_dollar_expression( { /* if variable is set, substitute remainer */ (*ptr)+=2; - if (parse_expression(str,ptr,'}',buffer,buflen,expander,expander_arg)==NULL) - return NULL; - if ((varvalue==NULL)||(*varvalue=='\0')) + if ((varvalue!=NULL)&&(*varvalue!='\0')) + { + /* value is set, evaluate rest of expression */ + if (parse_expression(str,ptr,'}',buffer,buflen,expander,expander_arg)==NULL) + return NULL; + } + else + { + /* value is not set, skip rest of expression and blank */ + if (parse_expression(str,ptr,'}',buffer,buflen,empty_expander,NULL)==NULL) + return NULL; buffer[0]='\0'; + } } else return NULL; |