X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=unix%2Fuxmisc.c;h=daa61a0193665909755938231c0d10a84ce703ba;hb=19aefec3e8b33f12e6edbead1028c07b5f486ce0;hp=e6ad3906a97acc9c004a3944a9c8458f50d9e809;hpb=b266d671acee34f9305950bfd87054b3b7fcded6;p=PuTTY.git diff --git a/unix/uxmisc.c b/unix/uxmisc.c index e6ad3906..daa61a01 100644 --- a/unix/uxmisc.c +++ b/unix/uxmisc.c @@ -95,6 +95,13 @@ Filename *filename_deserialise(void *vdata, int maxsize, int *used) return filename_from_str(data); } +char filename_char_sanitise(char c) +{ + if (c == '/') + return '.'; + return c; +} + #ifdef DEBUG static FILE *debug_fp = NULL; @@ -163,9 +170,11 @@ void pgp_fingerprints(void) "one. See the manual for more information.\n" "(Note: these fingerprints have nothing to do with SSH!)\n" "\n" - "PuTTY Master Key (RSA), 1024-bit:\n" + "PuTTY Master Key as of 2015 (RSA, 4096-bit):\n" + " " PGP_MASTER_KEY_FP "\n\n" + "Original PuTTY Master Key (RSA, 1024-bit):\n" " " PGP_RSA_MASTER_KEY_FP "\n" - "PuTTY Master Key (DSA), 1024-bit:\n" + "Original PuTTY Master Key (DSA, 1024-bit):\n" " " PGP_DSA_MASTER_KEY_FP "\n", stdout); } @@ -313,3 +322,30 @@ char *make_dir_and_check_ours(const char *dirname) return NULL; } + +char *make_dir_path(const char *path, mode_t mode) +{ + int pos = 0; + char *prefix; + + while (1) { + pos += strcspn(path + pos, "/"); + + if (pos > 0) { + prefix = dupprintf("%.*s", pos, path); + + if (mkdir(prefix, mode) < 0 && errno != EEXIST) { + char *ret = dupprintf("%s: mkdir: %s", + prefix, strerror(errno)); + sfree(prefix); + return ret; + } + + sfree(prefix); + } + + if (!path[pos]) + return NULL; + pos += strspn(path + pos, "/"); + } +}