Sun Oct 1 20:39:34 CEST 2006 Jochen Eisinger <coffee@silcnet.org>
[silc.git] / lib / silcutil / unix / silcunixutil.c
index 92bfaded55911cd5944a027db0df3d26407badc0..24c93a1c5c4fdfa8e6386d5463d6695efd6bab85 100644 (file)
@@ -135,13 +135,13 @@ char *silc_get_username()
   char *logname = NULL;
   
   logname = getenv("LOGNAME");
-  if (!logname) {
+  if (!logname || !strlen(logname)) {
     logname = getlogin();
-    if (!logname) {
+    if (!logname || !strlen(logname)) {
       struct passwd *pw;
 
       pw = getpwuid(getuid());
-      if (!pw)
+      if (!pw || !strlen(pw->pw_name))
        return strdup("foo");
 
       logname = pw->pw_name;