Merge branch 'maint' into next
authorAndre Noll <maan@systemlinux.org>
Thu, 22 Oct 2009 20:51:20 +0000 (22:51 +0200)
committerAndre Noll <maan@systemlinux.org>
Thu, 22 Oct 2009 20:51:20 +0000 (22:51 +0200)
1  2 
daemon.c
user_list.c

diff --combined daemon.c
index 0bc4b116e621726a0f1cb963436881c94fa4e6bc,011ece6d3d7689b34e793fb4b00f813afc324fc2..c855daa19e194ee5d6e432f89771b907bd909340
+++ b/daemon.c
@@@ -5,14 -5,12 +5,14 @@@
   */
  
  /** \file daemon.c Some helpers for programs that detach from the console. */
 -#include "para.h"
 -#include "daemon.h"
 +
 +#include <regex.h>
  #include <pwd.h>
  #include <sys/types.h> /* getgrnam() */
  #include <grp.h>
  
 +#include "para.h"
 +#include "daemon.h"
  #include "string.h"
  #include "color.h"
  
@@@ -271,7 -269,11 +271,11 @@@ void drop_privileges_or_die(const char 
                exit(EXIT_FAILURE);
        }
        PARA_INFO_LOG("dropping root privileges\n");
-       setuid(p->pw_uid);
+       if (setuid(p->pw_uid) < 0) {
+               PARA_EMERG_LOG("failed to set effective user ID (%s)",
+                       strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        PARA_DEBUG_LOG("uid: %d, euid: %d\n", (int)getuid(), (int)geteuid());
  }
  
@@@ -329,7 -331,7 +333,7 @@@ __printf_2_3 void para_log(int ll, cons
        FILE *fp;
        struct tm *tm;
        time_t t1;
-       char *color, str[MAXLINE] = "";
+       char *color;
  
        ll = PARA_MIN(ll, NUM_LOGLEVELS - 1);
        ll = PARA_MAX(ll, LL_DEBUG);
        color = daemon_test_flag(DF_COLOR_LOG)? me->log_colors[ll] : NULL;
        if (color)
                fprintf(fp, "%s", color);
-       if (daemon_test_flag(DF_LOG_TIME)) {
-               /* date and time */
+       if (daemon_test_flag(DF_LOG_TIME)) { /* print date and time */
+               char str[100];
                time(&t1);
                tm = localtime(&t1);
-               strftime(str, MAXLINE, "%b %d %H:%M:%S", tm);
+               strftime(str, sizeof(str), "%b %d %H:%M:%S", tm);
                fprintf(fp, "%s ", str);
        }
        if (daemon_test_flag(DF_LOG_HOSTNAME)) {
diff --combined user_list.c
index f1b4b212e11f3e1d807d9a78d1ac31b6d17cf9ca,f5aabc0979fa8d1feb1e60722cfd00451d5dfe1a..525a47dfac7ce6705859836c67998cf3e9358107
@@@ -6,19 -6,15 +6,19 @@@
  
  /** \file user_list.c User handling for para_server. */
  
 +#include <regex.h>
  #include <sys/types.h>
  #include <dirent.h>
 +#include <openssl/rc4.h>
  
  #include "para.h"
  #include "error.h"
 +#include "crypt.h"
  #include "fd.h"
  #include "string.h"
  #include "list.h"
  #include "user_list.h"
 +#include "rc4.h"
  
  static struct list_head user_list;
  
@@@ -43,7 -39,7 +43,7 @@@ static void populate_user_list(char *us
                struct user *u;
                RSA *rsa;
  
-               ret = para_fgets(line, MAXLINE, file_ptr);
+               ret = para_fgets(line, sizeof(line), file_ptr);
                if (ret <= 0)
                        break;
                if (sscanf(line,"%200s %200s %200s %200s", w, n, k, p) < 3)
                                para_strerror(-ret));
                        continue;
                }
 +              /*
 +               * In order to encrypt len := CHALLENGE_SIZE + 2 * RC4_KEY_LEN
 +               * bytes using RSA_public_encrypt() with EME-OAEP padding mode,
 +               * RSA_size(rsa) must be greater than len + 41. So ignore keys
 +               * which are too short. For details see RSA_public_encrypt(3).
 +               */
 +              if (ret <= CHALLENGE_SIZE + 2 * RC4_KEY_LEN + 41) {
 +                      PARA_WARNING_LOG("rsa key %s too short (%d)\n",
 +                              k, ret);
 +                      rsa_free(rsa);
 +                      continue;
 +              }
                u = para_malloc(sizeof(*u));
                u->name = para_strdup(n);
                u->rsa = rsa;