nss-pam-ldapd commit: r1168 - nss-pam-ldapd/common
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
nss-pam-ldapd commit: r1168 - nss-pam-ldapd/common
- From: "Commits of the nss-pam-ldapd project." <nss-pam-ldapd-commits [at] lists.arthurdejong.org>
- To: nss-pam-ldapd-commits [at] lists.arthurdejong.org
- Reply-to: nss-pam-ldapd-users [at] lists.arthurdejong.org
- Subject: nss-pam-ldapd commit: r1168 - nss-pam-ldapd/common
- Date: Sat, 14 Aug 2010 15:00:16 +0200 (CEST)
Author: arthur
Date: Sat Aug 14 15:00:13 2010
New Revision: 1168
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1168
Log:
do not expand variables in rest of ${var:-rest} expressions
Modified:
nss-pam-ldapd/common/expr.c
Modified: nss-pam-ldapd/common/expr.c
==============================================================================
--- nss-pam-ldapd/common/expr.c Tue Jul 27 08:26:08 2010 (r1167)
+++ nss-pam-ldapd/common/expr.c Sat Aug 14 15:00:13 2010 (r1168)
@@ -2,7 +2,7 @@
expr.c - limited shell-like expression parsing functions
This file is part of the nss-pam-ldapd library.
- Copyright (C) 2009 Arthur de Jong
+ Copyright (C) 2009, 2010 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -24,8 +24,10 @@
#include <stdlib.h>
#include <string.h>
+#include <stdio.h>
#include "expr.h"
+#include "compat/attrs.h"
/* the maximum length of a variable name */
#define MAXVARLENGTH 30
@@ -40,8 +42,6 @@
return my_isalpha(c)||((c>='0')&&(c<='9'));
}
-#include <stdio.h>
-
/* return the part of the string that is a valid name */
MUST_USE static const char *parse_name(const char *str,int *ptr,char
*buffer,size_t buflen)
{
@@ -64,6 +64,12 @@
return buffer;
}
+/* dummy expander function to always return an empty string */
+static const char *empty_expander(const char UNUSED(*name),void
UNUSED(*expander_arg))
+{
+ return "";
+}
+
/* definition of the parse functions (they call eachother) */
MUST_USE static const char *parse_dollar_expression(
const char *str,int *ptr,char *buffer,size_t buflen,
@@ -98,14 +104,21 @@
{
/* if variable is not set or empty, substitute remainder */
(*ptr)+=2;
- if
(parse_expression(str,ptr,'}',buffer,buflen,expander,expander_arg)==NULL)
- return NULL;
if ((varvalue!=NULL)&&(*varvalue!='\0'))
{
+ /* value is set, skip rest of expression and use value */
+ if
(parse_expression(str,ptr,'}',buffer,buflen,empty_expander,NULL)==NULL)
+ return NULL;
if (strlen(varvalue)>=buflen)
return NULL;
strcpy(buffer,varvalue);
}
+ else
+ {
+ /* value is not set, evaluate rest of expression */
+ if
(parse_expression(str,ptr,'}',buffer,buflen,expander,expander_arg)==NULL)
+ return NULL;
+ }
}
else if (strncmp(str+*ptr,":+",2)==0)
{
--
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits
- nss-pam-ldapd commit: r1168 - nss-pam-ldapd/common,
Commits of the nss-pam-ldapd project.