tenseleyflow/gitswitch / 29ed60f

Browse files

fixes

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
29ed60ffbc4f35887174b2700454002f87749af9
Parents
5d5a0ca
Tree
d8388f5

2 changed files

StatusFile+-
M src/accounts.c 13 3
M src/display.c 8 5
src/accounts.cmodified
@@ -724,10 +724,20 @@ static int validate_ssh_key_security(const char *ssh_key_path) {
724724
         return -1;
725725
     }
726726
     
727
+    /* Check if it's a private key (should be 600) or public key (can be 644) */
728
+    if (strstr(ssh_key_path, ".pub") == NULL) {
729
+        /* Private key - should be 600 */
727730
         if ((file_mode & 077) != 0) {
728
-        log_warning("SSH key file has insecure permissions: %o", file_mode & 0777);
731
+            log_warning("SSH private key file has insecure permissions: %o", file_mode & 0777);
729732
             return -1;
730733
         }
734
+    } else {
735
+        /* Public key - 644 is acceptable */
736
+        if ((file_mode & 022) != 0 && (file_mode & 044) == 0) {
737
+            log_warning("SSH public key file has unusual permissions: %o", file_mode & 0777);
738
+            /* Continue anyway for public keys */
739
+        }
740
+    }
731741
     
732742
     /* Check if it looks like a valid SSH key */
733743
     key_file = fopen(ssh_key_path, "r");
src/display.cmodified
@@ -135,8 +135,7 @@ void display_header(const char *title) {
135135
     printf("┐\n");
136136
     
137137
     /* Title line */
138
-    printf("│%s%*s%s%s%*s│\n", 
139
-           display_colorize("", "header"),
138
+    printf("│%*s%s%s%*s│\n", 
140139
            padding, "",
141140
            display_colorize(title, "header"),
142141
            COLOR_RESET,
@@ -182,9 +181,13 @@ void display_status(const char *level, const char *message, ...) {
182181
         color_type = "info";
183182
     }
184183
     
184
+    if (strlen(formatted_message) > 0) {
185185
         printf("%s %s\n", 
186186
                display_colorize(icon, color_type),
187187
                display_colorize(formatted_message, color_type));
188
+    } else {
189
+        printf("%s\n", display_colorize(icon, color_type));
190
+    }
188191
 }
189192
 
190193
 /* Print error message with context */