From: Andre Noll Date: Thu, 22 Oct 2009 20:51:09 +0000 (+0200) Subject: Merge branch 'maint' X-Git-Tag: v0.4.0~7 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=11e68b8de3eb8bf8b657333d5b8359260559e93b;hp=-c Merge branch 'maint' --- 11e68b8de3eb8bf8b657333d5b8359260559e93b diff --combined daemon.c index 0bc4b116,011ece6d..c855daa1 --- a/daemon.c +++ 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 #include #include /* getgrnam() */ #include +#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); @@@ -340,11 -342,11 +344,11 @@@ 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 f1b4b212,f5aabc09..525a47df --- a/user_list.c +++ b/user_list.c @@@ -6,19 -6,15 +6,19 @@@ /** \file user_list.c User handling for para_server. */ +#include #include #include +#include #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) @@@ -57,18 -53,6 +57,18 @@@ 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;