Whine if single-DES keys are in use
[openafs.git] / src / util / serverLog.c
index 7c5eae1..d51c352 100644 (file)
 #include <afs/procmgmt.h>      /* signal(), kill(), wait(), etc. */
 
 #include <roken.h>             /* Must come after procmgmt.h */
+#include <afs/opr.h>
 
+#include <afs/opr.h>
 #include "afsutil.h"
 #include "fileutil.h"
 #include <lwp.h>
 
 #if defined(AFS_PTHREAD_ENV)
-#include <afs/afs_assert.h>
-/* can't include rx when we are libutil; it's too early */
-#include <rx/rx.h>
 #include <pthread.h>
 static pthread_mutex_t serverLogMutex;
-#define LOCK_SERVERLOG() MUTEX_ENTER(&serverLogMutex)
-#define UNLOCK_SERVERLOG() MUTEX_EXIT(&serverLogMutex)
+#define LOCK_SERVERLOG() opr_Verify(pthread_mutex_lock(&serverLogMutex) == 0)
+#define UNLOCK_SERVERLOG() opr_Verify(pthread_mutex_unlock(&serverLogMutex) == 0)
 
 #ifdef AFS_NT40_ENV
 #define NULLDEV "NUL"
@@ -68,7 +67,6 @@ int serverLogSyslogFacility = LOG_DAEMON;
 char *serverLogSyslogTag = 0;
 #endif
 
-#include <stdarg.h>
 int LogLevel;
 int mrafsStyleLogs = 0;
 static int threadIdLogs = 0;
@@ -161,6 +159,8 @@ LogCommandLine(int argc, char **argv, const char *progname,
     int i, l;
     char *commandLine, *cx;
 
+    opr_Assert(argc > 0);
+
     for (l = i = 0; i < argc; i++)
        l += strlen(argv[i]) + 1;
     if ((commandLine = malloc(l))) {
@@ -180,6 +180,19 @@ LogCommandLine(int argc, char **argv, const char *progname,
     }
 }
 
+void
+LogDesWarning(void)
+{
+    /* The blank newlines help this stand out a bit more in the log. */
+    ViceLog(0, ("\n"));
+    ViceLog(0, ("WARNING: You are using single-DES keys in a KeyFile. Using single-DES\n"));
+    ViceLog(0, ("WARNING: long-term keys is considered insecure, and it is strongly\n"));
+    ViceLog(0, ("WARNING: recommended that you migrate to stronger encryption. See\n"));
+    ViceLog(0, ("WARNING: OPENAFS-SA-2013-003 on http://www.openafs.org/security/\n"));
+    ViceLog(0, ("WARNING: for details.\n"));
+    ViceLog(0, ("\n"));
+}
+
 static void*
 DebugOn(void *param)
 {
@@ -312,7 +325,7 @@ OpenLog(const char *fileName)
            goto makefilename;
        }
        if (!isfifo)
-           renamefile(fileName, FileName);     /* don't check error code */
+           rk_rename(fileName, FileName);      /* don't check error code */
        tempfd = open(fileName, O_WRONLY | O_TRUNC | O_CREAT | (isfifo?O_NONBLOCK:0), 0666);
     } else {
        strcpy(oldName, fileName);
@@ -320,7 +333,7 @@ OpenLog(const char *fileName)
 
        /* don't check error */
        if (!isfifo)
-           renamefile(fileName, oldName);
+           rk_rename(fileName, oldName);
        tempfd = open(fileName, O_WRONLY | O_TRUNC | O_CREAT | (isfifo?O_NONBLOCK:0), 0666);
     }
 
@@ -338,7 +351,7 @@ OpenLog(const char *fileName)
 #endif
 
 #if defined(AFS_PTHREAD_ENV)
-    MUTEX_INIT(&serverLogMutex, "serverlog", MUTEX_DEFAULT, 0);
+    opr_Verify(pthread_mutex_init(&serverLogMutex, NULL) == 0);
 #endif /* AFS_PTHREAD_ENV */
 
     serverLogFD = tempfd;