[BACK]Return to hostfile.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/hostfile.c between version 1.80 and 1.81

version 1.80, 2020/05/13 09:52:41 version 1.81, 2020/06/26 05:02:03
Line 55 
Line 55 
 #include "hostfile.h"  #include "hostfile.h"
 #include "log.h"  #include "log.h"
 #include "misc.h"  #include "misc.h"
   #include "pathnames.h"
 #include "ssherr.h"  #include "ssherr.h"
 #include "digest.h"  #include "digest.h"
 #include "hmac.h"  #include "hmac.h"
Line 448 
Line 449 
 }  }
   
 /*  /*
    * Create user ~/.ssh directory if it doesn't exist and we want to write to it.
    * If notify is set, a message will be emitted if the directory is created.
    */
   void
   hostfile_create_user_ssh_dir(const char *filename, int notify)
   {
           char *dotsshdir = NULL, *p;
           size_t len;
           struct stat st;
   
           if ((p = strrchr(filename, '/')) == NULL)
                   return;
           len = p - filename;
           dotsshdir = tilde_expand_filename("~/" _PATH_SSH_USER_DIR, getuid());
           if ((strlen(dotsshdir) > len || strncmp(filename, dotsshdir, len) != 0
               || stat(dotsshdir, &st)) == 0)
                   ; /* do nothing, path not in ~/.ssh or dir already exists */
           else if (errno != ENOENT)
                   error("Could not stat %s: %s", dotsshdir, strerror(errno));
           else if (mkdir(dotsshdir, 0700) == -1)
                   error("Could not create directory '%.200s' (%s).",
                       dotsshdir, strerror(errno));
           else if (notify)
                   logit("Created directory '%s'.", dotsshdir);
           free(dotsshdir);
   }
   
   /*
  * Appends an entry to the host file.  Returns false if the entry could not   * Appends an entry to the host file.  Returns false if the entry could not
  * be appended.   * be appended.
  */   */
Line 460 
Line 489 
   
         if (key == NULL)          if (key == NULL)
                 return 1;       /* XXX ? */                  return 1;       /* XXX ? */
           hostfile_create_user_ssh_dir(filename, 0);
         f = fopen(filename, "a");          f = fopen(filename, "a");
         if (!f)          if (!f)
                 return 0;                  return 0;

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.81