Bump to version 1.22.1
[platform/upstream/busybox.git] / miscutils / devfsd.c
index cd94869..96ffe07 100644 (file)
@@ -1,6 +1,6 @@
 /* vi: set sw=4 ts=4: */
 /*
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
 /*
       Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.
 */
 
-//#include <sys/wait.h>
-//#include <sys/ioctl.h>
-//#include <sys/socket.h>
-#include <sys/un.h>
-#include <dirent.h>
-#include <syslog.h>
-#include <sys/sysmacros.h>
+//usage:#define devfsd_trivial_usage
+//usage:       "mntpnt [-v]" IF_DEVFSD_FG_NP("[-fg][-np]")
+//usage:#define devfsd_full_usage "\n\n"
+//usage:       "Manage devfs permissions and old device name symlinks\n"
+//usage:     "\n       mntpnt  The mount point where devfs is mounted"
+//usage:     "\n       -v      Print the protocol version numbers for devfsd"
+//usage:     "\n               and the kernel-side protocol version and exit"
+//usage:       IF_DEVFSD_FG_NP(
+//usage:     "\n       -fg     Run in foreground"
+//usage:     "\n       -np     Exit after parsing the configuration file"
+//usage:     "\n               and processing synthetic REGISTER events,"
+//usage:     "\n               don't poll for events"
+//usage:       )
+
 #include "libbb.h"
 #include "xregex.h"
+#include <syslog.h>
 
+#include <sys/un.h>
+#include <sys/sysmacros.h>
 
 /* Various defines taken from linux/major.h */
 #define IDE0_MAJOR     3
@@ -80,7 +90,7 @@
 
 /* Various defines taken from linux/devfs_fs.h */
 #define DEVFSD_PROTOCOL_REVISION_KERNEL  5
-#define        DEVFSD_IOCTL_BASE       'd'
+#define DEVFSD_IOCTL_BASE      'd'
 /*  These are the various ioctls  */
 #define DEVFSDIOC_GET_PROTO_REV         _IOR(DEVFSD_IOCTL_BASE, 0, int)
 #define DEVFSDIOC_SET_EVENT_MASK        _IOW(DEVFSD_IOCTL_BASE, 2, int)
 #define DEVFS_PATHLEN               1024
 /*  Never change this otherwise the binary interface will change   */
 
-struct devfsd_notify_struct
-{   /*  Use native C types to ensure same types in kernel and user space     */
-    unsigned int type;           /*  DEVFSD_NOTIFY_* value                   */
-    unsigned int mode;           /*  Mode of the inode or device entry       */
-    unsigned int major;          /*  Major number of device entry            */
-    unsigned int minor;          /*  Minor number of device entry            */
-    unsigned int uid;            /*  Uid of process, inode or device entry   */
-    unsigned int gid;            /*  Gid of process, inode or device entry   */
-    unsigned int overrun_count;  /*  Number of lost events                   */
-    unsigned int namelen;        /*  Number of characters not including '\0' */
-    /*  The device name MUST come last                                       */
-    char devname[DEVFS_PATHLEN]; /*  This will be '\0' terminated            */
+struct devfsd_notify_struct {
+       /*  Use native C types to ensure same types in kernel and user space     */
+       unsigned int type;           /*  DEVFSD_NOTIFY_* value                   */
+       unsigned int mode;           /*  Mode of the inode or device entry       */
+       unsigned int major;          /*  Major number of device entry            */
+       unsigned int minor;          /*  Minor number of device entry            */
+       unsigned int uid;            /*  Uid of process, inode or device entry   */
+       unsigned int gid;            /*  Gid of process, inode or device entry   */
+       unsigned int overrun_count;  /*  Number of lost events                   */
+       unsigned int namelen;        /*  Number of characters not including '\0' */
+       /*  The device name MUST come last                                       */
+       char devname[DEVFS_PATHLEN]; /*  This will be '\0' terminated            */
 };
 
 #define BUFFER_SIZE 16384
@@ -156,32 +166,27 @@ struct devfsd_notify_struct
 #define AC_RMNEWCOMPAT                         10
 #define AC_RESTORE                                     11
 
-struct permissions_type
-{
+struct permissions_type {
        mode_t mode;
        uid_t uid;
        gid_t gid;
 };
 
-struct execute_type
-{
+struct execute_type {
        char *argv[MAX_ARGS + 1];  /*  argv[0] must always be the programme  */
 };
 
-struct copy_type
-{
+struct copy_type {
        const char *source;
        const char *destination;
 };
 
-struct action_type
-{
+struct action_type {
        unsigned int what;
        unsigned int when;
 };
 
-struct config_entry_struct
-{
+struct config_entry_struct {
        struct action_type action;
        regex_t preg;
        union
@@ -194,8 +199,7 @@ struct config_entry_struct
        struct config_entry_struct *next;
 };
 
-struct get_variable_info
-{
+struct get_variable_info {
        const struct devfsd_notify_struct *info;
        const char *devname;
        char devpath[STRING_LENGTH];
@@ -215,7 +219,7 @@ static void action_execute(const struct devfsd_notify_struct *, const struct con
                                                        const regmatch_t *, unsigned);
 static void action_modload(const struct devfsd_notify_struct *info, const struct config_entry_struct *entry);
 static void action_copy(const struct devfsd_notify_struct *, const struct config_entry_struct *,
-                                                const regmatch_t *, unsigned);
+                                               const regmatch_t *, unsigned);
 static void action_compat(const struct devfsd_notify_struct *, unsigned);
 static void free_config(void);
 static void restore(char *spath, struct stat source_stat, int rootlen);
@@ -225,12 +229,12 @@ static void signal_handler(int);
 static const char *get_variable(const char *, void *);
 static int make_dir_tree(const char *);
 static int expand_expression(char *, unsigned, const char *, const char *(*)(const char *, void *), void *,
-                                                        const char *, const regmatch_t *, unsigned);
+                                                       const char *, const regmatch_t *, unsigned);
 static void expand_regexp(char *, size_t, const char *, const char *, const regmatch_t *, unsigned);
 static const char *expand_variable(    char *, unsigned, unsigned *, const char *,
                                                                        const char *(*)(const char *, void *), void *);
 static const char *get_variable_v2(const char *, const char *(*)(const char *, void *), void *);
-static char get_old_ide_name(unsigned , unsigned);
+static char get_old_ide_name(unsigned, unsigned);
 static char *write_old_sd_name(char *, unsigned, unsigned, const char *);
 
 /* busybox functions */
@@ -288,9 +292,9 @@ static const char bb_msg_variable_not_found[] ALIGN1 = "variable: %s not found";
 #else
 #define info_logger(p, fmt, args...)
 #define msg_logger(p, fmt, args...)
-#define msg_logger_and_die(p, fmt, args...)           exit(1)
+#define msg_logger_and_die(p, fmt, args...)           exit(EXIT_FAILURE)
 #define error_logger(p, fmt, args...)
-#define error_logger_and_die(p, fmt, args...)         exit(1)
+#define error_logger_and_die(p, fmt, args...)         exit(EXIT_FAILURE)
 #endif
 
 static void safe_memcpy(char *dest, const char *src, int len)
@@ -391,15 +395,14 @@ int devfsd_main(int argc, char **argv)
        /*  Tell kernel we are special(i.e. we get to see hidden entries)  */
        xioctl(fd, DEVFSDIOC_SET_EVENT_MASK, 0);
 
+       /*  Set up SIGHUP and SIGUSR1 handlers  */
        sigemptyset(&new_action.sa_mask);
        new_action.sa_flags = 0;
-
-       /*  Set up SIGHUP and SIGUSR1 handlers  */
        new_action.sa_handler = signal_handler;
-       if (sigaction(SIGHUP, &new_action, NULL) != 0 || sigaction(SIGUSR1, &new_action, NULL) != 0)
-               bb_error_msg_and_die("sigaction");
+       sigaction_set(SIGHUP, &new_action);
+       sigaction_set(SIGUSR1, &new_action);
 
-       printf("%s v%s  started for %s\n",applet_name, DEVFSD_VERSION, mount_point);
+       printf("%s v%s started for %s\n", applet_name, DEVFSD_VERSION, mount_point);
 
        /*  Set umask so that mknod(2), open(2) and mkdir(2) have complete control over permissions  */
        umask(0);
@@ -408,7 +411,7 @@ int devfsd_main(int argc, char **argv)
        dir_operation(SERVICE, mount_point, 0, NULL);
 
        if (ENABLE_DEVFSD_FG_NP && no_polling)
-               exit(0);
+               exit(EXIT_SUCCESS);
 
        if (ENABLE_DEVFSD_VERBOSE || ENABLE_DEBUG)
                logmode = LOGMODE_BOTH;
@@ -465,7 +468,8 @@ static void read_config_file(char *path, int optional, unsigned long *event_mask
                        free(p);
                        return;
                }
-               if ((fp = fopen(path, "r")) != NULL) {
+               fp = fopen_for_read(path);
+               if (fp != NULL) {
                        while (fgets(buf, STRING_LENGTH, fp) != NULL) {
                                /*  Skip whitespace  */
                                line = buf;
@@ -560,7 +564,8 @@ static void process_config_line(const char *line, unsigned long *event_mask)
                case 4: /* "PERMISSIONS" */
                        new->action.what = AC_PERMISSIONS;
                        /*  Get user and group  */
-                       if ((ptr = strchr(p[0], '.')) == NULL) {
+                       ptr = strchr(p[0], '.');
+                       if (ptr == NULL) {
                                msg = "UID.GID";
                                goto process_config_line_err; /*"missing '.' in UID.GID"*/
                        }
@@ -575,9 +580,9 @@ static void process_config_line(const char *line, unsigned long *event_mask)
                        /*This  action will pass "/dev/$devname"(i.e. "/dev/" prefixed to
                        the device name) to the module loading  facility.  In  addition,
                        the /etc/modules.devfs configuration file is used.*/
-                        if (ENABLE_DEVFSD_MODLOAD)
+                       if (ENABLE_DEVFSD_MODLOAD)
                                new->action.what = AC_MODLOAD;
-                        break;
+                       break;
                case 6: /* EXECUTE */
                        new->action.what = AC_EXECUTE;
                        num_args -= 3;
@@ -647,7 +652,7 @@ static int do_servicing(int fd, unsigned long event_mask)
        xioctl(fd, DEVFSDIOC_SET_EVENT_MASK, (void*)event_mask);
        while (!caught_signal) {
                errno = 0;
-               bytes = read(fd,(char *) &info, sizeof info);
+               bytes = read(fd, (char *) &info, sizeof info);
                if (caught_signal)
                        break;      /*  Must test for this first     */
                if (errno == EINTR)
@@ -745,7 +750,7 @@ static void action_permissions(const struct devfsd_notify_struct *info,
 }   /*  End Function action_permissions  */
 
 static void action_modload(const struct devfsd_notify_struct *info,
-                           const struct config_entry_struct *entry ATTRIBUTE_UNUSED)
+                       const struct config_entry_struct *entry UNUSED_PARAM)
 /*  [SUMMARY] Load a module.
     <info> The devfs change.
     <entry> The config file entry.
@@ -761,13 +766,13 @@ static void action_modload(const struct devfsd_notify_struct *info,
        argv[4] = concat_path_file("/dev", info->devname); /* device */
        argv[5] = NULL;
 
-       wait4pid(xspawn(argv));
+       spawn_and_wait(argv);
        free(argv[4]);
 }  /*  End Function action_modload  */
 
 static void action_execute(const struct devfsd_notify_struct *info,
-                           const struct config_entry_struct *entry,
-                           const regmatch_t *regexpr, unsigned int numexpr)
+                       const struct config_entry_struct *entry,
+                       const regmatch_t *regexpr, unsigned int numexpr)
 /*  [SUMMARY] Execute a programme.
     <info> The devfs change.
     <entry> The config file entry.
@@ -793,13 +798,13 @@ static void action_execute(const struct devfsd_notify_struct *info,
                argv[count] = largv[count];
        }
        argv[count] = NULL;
-       wait4pid(spawn(argv));
+       spawn_and_wait(argv);
 }   /*  End Function action_execute  */
 
 
 static void action_copy(const struct devfsd_notify_struct *info,
-                        const struct config_entry_struct *entry,
-                        const regmatch_t *regexpr, unsigned int numexpr)
+                       const struct config_entry_struct *entry,
+                       const regmatch_t *regexpr, unsigned int numexpr)
 /*  [SUMMARY] Copy permissions.
     <info> The devfs change.
     <entry> The config file entry.
@@ -951,10 +956,10 @@ static void restore(char *spath, struct stat source_stat, int rootlen)
        lstat(dpath, &dest_stat);
        free(dpath);
        if (S_ISLNK(source_stat.st_mode) || (source_stat.st_mode & S_ISVTX))
-               copy_inode(dpath, &dest_stat,(source_stat.st_mode & ~S_ISVTX) , spath, &source_stat);
+               copy_inode(dpath, &dest_stat, (source_stat.st_mode & ~S_ISVTX), spath, &source_stat);
 
        if (S_ISDIR(source_stat.st_mode))
-               dir_operation(RESTORE, spath, rootlen,NULL);
+               dir_operation(RESTORE, spath, rootlen, NULL);
 }
 
 
@@ -979,8 +984,9 @@ static int copy_inode(const char *destpath, const struct stat *dest_stat,
        if ((source_stat->st_mode & S_IFMT) ==(dest_stat->st_mode & S_IFMT)) {
                /*  Same type  */
                if (S_ISLNK(source_stat->st_mode)) {
-                       if ((source_len = readlink(sourcepath, source_link, STRING_LENGTH - 1)) < 0
-                               || (dest_len   = readlink(destpath  , dest_link  , STRING_LENGTH - 1)) < 0
+                       source_len = readlink(sourcepath, source_link, STRING_LENGTH - 1);
+                       if ((source_len < 0)
+                        || (dest_len = readlink(destpath, dest_link, STRING_LENGTH - 1)) < 0
                        )
                                return FALSE;
                        source_link[source_len] = '\0';
@@ -999,24 +1005,27 @@ static int copy_inode(const char *destpath, const struct stat *dest_stat,
        unlink(destpath);
        switch (source_stat->st_mode & S_IFMT) {
                case S_IFSOCK:
-                       if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
+                       fd = socket(AF_UNIX, SOCK_STREAM, 0);
+                       if (fd < 0)
                                break;
                        un_addr.sun_family = AF_UNIX;
                        snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s", destpath);
-                       val = bind(fd,(struct sockaddr *) &un_addr,(int) sizeof un_addr);
+                       val = bind(fd, (struct sockaddr *) &un_addr, (int) sizeof un_addr);
                        close(fd);
                        if (val != 0 || chmod(destpath, new_mode & ~S_IFMT) != 0)
                                break;
                        goto do_chown;
                case S_IFLNK:
-                       if ((val = readlink(sourcepath, symlink_val, STRING_LENGTH - 1)) < 0)
+                       val = readlink(sourcepath, symlink_val, STRING_LENGTH - 1);
+                       if (val < 0)
                                break;
                        symlink_val[val] = '\0';
                        if (symlink(symlink_val, destpath) == 0)
                                return TRUE;
                        break;
                case S_IFREG:
-                       if ((fd = open(destpath, O_RDONLY | O_CREAT, new_mode & ~S_IFMT)) < 0)
+                       fd = open(destpath, O_RDONLY | O_CREAT, new_mode & ~S_IFMT);
+                       if (fd < 0)
                                break;
                        close(fd);
                        if (chmod(destpath, new_mode & ~S_IFMT) != 0)
@@ -1074,24 +1083,26 @@ static int get_uid_gid(int flag, const char *string)
 {
        struct passwd *pw_ent;
        struct group *grp_ent;
-       static const char *msg;
+       const char *msg;
 
-       if (ENABLE_DEVFSD_VERBOSE)
-               msg = "user";
-
-       if (isdigit(string[0]) ||((string[0] == '-') && isdigit(string[1])))
+       if (isdigit(string[0]) || ((string[0] == '-') && isdigit(string[1])))
                return atoi(string);
 
-       if (flag == UID && (pw_ent  = getpwnam(string)) != NULL)
+       if (flag == UID && (pw_ent = getpwnam(string)) != NULL)
                return pw_ent->pw_uid;
 
-       if (flag == GID && (grp_ent = getgrnam(string)) != NULL)
-               return grp_ent->gr_gid;
-       else if (ENABLE_DEVFSD_VERBOSE)
-               msg = "group";
+       if (ENABLE_DEVFSD_VERBOSE)
+               msg = "user";
+
+       if (flag == GID) {
+               if ((grp_ent = getgrnam(string)) != NULL)
+                       return grp_ent->gr_gid;
+               if (ENABLE_DEVFSD_VERBOSE)
+                       msg = "group";
+       }
 
        if (ENABLE_DEVFSD_VERBOSE)
-               msg_logger(LOG_ERR,"unknown %s: %s, defaulting to %cid=0",  msg, string, msg[0]);
+               msg_logger(LOG_ERR, "unknown %s: %s, defaulting to %cid=0",  msg, string, msg[0]);
        return 0;
 }/*  End Function get_uid_gid  */
 
@@ -1132,8 +1143,8 @@ static void signal_handler(int sig)
 static const char *get_variable(const char *variable, void *info)
 {
        static char sbuf[sizeof(int)*3 + 2]; /* sign and NUL */
+       static char *hostname;
 
-       char hostname[STRING_LENGTH];
        struct get_variable_info *gv_info = info;
        const char *field_names[] = {
                        "hostname", "mntpt", "devpath", "devname",
@@ -1142,12 +1153,8 @@ static const char *get_variable(const char *variable, void *info)
        };
        int i;
 
-       if (gethostname(hostname, STRING_LENGTH - 1) != 0)
-               /* Here on error we should do exit(RV_SYS_ERROR), instead we do exit(EXIT_FAILURE) */
-               error_logger_and_die(LOG_ERR, "gethostname");
-
-       hostname[STRING_LENGTH - 1] = '\0';
-
+       if (!hostname)
+               hostname = safe_gethostname();
        /* index_in_str_array returns i>=0  */
        i = index_in_str_array(field_names, variable);
 
@@ -1197,7 +1204,8 @@ static void dir_operation(int type, const char * dir_name, int var, unsigned lon
        struct dirent *de;
        char *path;
 
-       if ((dp = warn_opendir(dir_name)) == NULL)
+       dp = warn_opendir(dir_name);
+       if (dp == NULL)
                return;
 
        while ((de = readdir(dp)) != NULL) {
@@ -1253,11 +1261,11 @@ static int make_dir_tree(const char *path)
 } /*  End Function make_dir_tree  */
 
 static int expand_expression(char *output, unsigned int outsize,
-                             const char *input,
-                             const char *(*get_variable_func)(const char *variable, void *info),
-                             void *info,
-                             const char *devname,
-                             const regmatch_t *ex, unsigned int numexp)
+                       const char *input,
+                       const char *(*get_variable_func)(const char *variable, void *info),
+                       void *info,
+                       const char *devname,
+                       const regmatch_t *ex, unsigned int numexp)
 /*  [SUMMARY] Expand environment variables and regular subexpressions in string.
     <output> The output expanded expression is written here.
     <length> The size of the output buffer.
@@ -1282,8 +1290,8 @@ static int expand_expression(char *output, unsigned int outsize,
 }   /*  End Function expand_expression  */
 
 static void expand_regexp(char *output, size_t outsize, const char *input,
-                          const char *devname,
-                          const regmatch_t *ex, unsigned int numex)
+                       const char *devname,
+                       const regmatch_t *ex, unsigned int numex)
 /*  [SUMMARY] Expand all occurrences of the regular subexpressions \0 to \9.
     <output> The output expanded expression is written here.
     <outsize> The size of the output buffer.
@@ -1339,8 +1347,7 @@ static void expand_regexp(char *output, size_t outsize, const char *input,
 
 /* from compat_name.c */
 
-struct translate_struct
-{
+struct translate_struct {
        const char *match;    /*  The string to match to(up to length)                */
        const char *format;   /*  Format of output, "%s" takes data past match string,
                        NULL is effectively "%s"(just more efficient)       */
@@ -1380,7 +1387,7 @@ static struct translate_struct translate_table[] =
 };
 
 const char *get_old_name(const char *devname, unsigned int namelen,
-                         char *buffer, unsigned int major, unsigned int minor)
+                       char *buffer, unsigned int major, unsigned int minor)
 /*  [SUMMARY] Translate a kernel-supplied name into an old name.
     <devname> The device name provided by the kernel.
     <namelen> The length of the name.
@@ -1418,7 +1425,7 @@ const char *get_old_name(const char *devname, unsigned int namelen,
        };
 
        for (trans = translate_table; trans->match != NULL; ++trans) {
-                len = strlen(trans->match);
+               len = strlen(trans->match);
 
                if (strncmp(devname, trans->match, len) == 0) {
                        if (trans->format == NULL)
@@ -1442,7 +1449,7 @@ const char *get_old_name(const char *devname, unsigned int namelen,
 
        /* 2 ==scsi/disc, 4 == scsi/part */
        if (i == 2 || i == 4)
-               compat_name = write_old_sd_name(buffer, major, minor,((i == 2) ? "" : (ptr + 4)));
+               compat_name = write_old_sd_name(buffer, major, minor, ((i == 2) ? "" : (ptr + 4)));
 
        /* 5 == scsi/mt */
        if (i == 5) {
@@ -1544,9 +1551,9 @@ static char *write_old_sd_name(char *buffer,
 /*EXPERIMENTAL_FUNCTION*/
 
 int st_expr_expand(char *output, unsigned int length, const char *input,
-                    const char *(*get_variable_func)(const char *variable,
-                                                 void *info),
-                    void *info)
+               const char *(*get_variable_func)(const char *variable,
+                                               void *info),
+               void *info)
 /*  [SUMMARY] Expand an expression using Borne Shell-like unquoted rules.
     <output> The output expanded expression is written here.
     <length> The size of the output buffer.
@@ -1581,7 +1588,8 @@ int st_expr_expand(char *output, unsigned int length, const char *input,
                                ch = input[1];
                                if (isspace(ch) ||(ch == '/') ||(ch == '\0')) {
                                        /* User's own home directory: leave separator for next time */
-                                       if ((env = getenv("HOME")) == NULL) {
+                                       env = getenv("HOME");
+                                       if (env == NULL) {
                                                info_logger(LOG_INFO, bb_msg_variable_not_found, "HOME");
                                                return FALSE;
                                        }
@@ -1600,7 +1608,8 @@ int st_expr_expand(char *output, unsigned int length, const char *input,
                                        goto st_expr_expand_out;
                                safe_memcpy(tmp, input, len);
                                input = ptr - 1;
-                               if ((pwent = getpwnam(tmp)) == NULL) {
+                               pwent = getpwnam(tmp);
+                               if (pwent == NULL) {
                                        info_logger(LOG_INFO, "no pwent for: %s", tmp);
                                        return FALSE;
                                }
@@ -1634,10 +1643,10 @@ st_expr_expand_out:
 /*  Private functions follow  */
 
 static const char *expand_variable(char *buffer, unsigned int length,
-                                   unsigned int *out_pos, const char *input,
-                                   const char *(*func)(const char *variable,
-                                                        void *info),
-                                   void *info)
+                               unsigned int *out_pos, const char *input,
+                               const char *(*func)(const char *variable,
+                                                       void *info),
+                               void *info)
 /*  [SUMMARY] Expand a variable.
     <buffer> The buffer to write to.
     <length> The length of the output buffer.
@@ -1660,7 +1669,7 @@ static const char *expand_variable(char *buffer, unsigned int length,
        ch = input[0];
        if (ch == '$') {
                /*  Special case for "$$": PID  */
-               sprintf(tmp, "%d",(int) getpid());
+               sprintf(tmp, "%d", (int) getpid());
                len = strlen(tmp);
                if (len + *out_pos >= length)
                        goto expand_variable_out;
@@ -1680,7 +1689,8 @@ static const char *expand_variable(char *buffer, unsigned int length,
 
                safe_memcpy(tmp, input, len);
                input = ptr - 1;
-               if ((env = get_variable_v2(tmp, func, info)) == NULL) {
+               env = get_variable_v2(tmp, func, info);
+               if (env == NULL) {
                        info_logger(LOG_INFO, bb_msg_variable_not_found, tmp);
                        return NULL;
                }
@@ -1732,7 +1742,7 @@ static const char *expand_variable(char *buffer, unsigned int length,
                                --open_braces;
                                break;
                        case '\0':
-                               info_logger(LOG_INFO,"\"}\" not found in: %s", input);
+                               info_logger(LOG_INFO, "\"}\" not found in: %s", input);
                                return NULL;
                        default:
                                break;
@@ -1740,7 +1750,8 @@ static const char *expand_variable(char *buffer, unsigned int length,
        }
        --ptr;
        /*  At this point ptr should point to closing brace of "${var:-word}"  */
-       if ((env = get_variable_v2(tmp, func, info)) != NULL) {
+       env = get_variable_v2(tmp, func, info);
+       if (env != NULL) {
                /*  Found environment variable, so skip the input to the closing brace
                        and return the variable  */
                input = ptr;
@@ -1777,8 +1788,8 @@ expand_variable_out:
 
 
 static const char *get_variable_v2(const char *variable,
-                                 const char *(*func)(const char *variable, void *info),
-                                void *info)
+                               const char *(*func)(const char *variable, void *info),
+                               void *info)
 /*  [SUMMARY] Get a variable from the environment or .
     <variable> The variable name.
     <func> A function which will be used to get the variable. If this returns