Mercurial > dropbear
comparison scp.c @ 1228:f7f2c3714269
Don't fail if can't get the username
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 19 Jan 2016 00:34:37 +0800 |
parents | 952624727411 |
children | 52a456a3add0 |
comparison
equal
deleted
inserted
replaced
1227:5dde22e8a189 | 1228:f7f2c3714269 |
---|---|
287 void nospace(void); | 287 void nospace(void); |
288 int okname(char *); | 288 int okname(char *); |
289 void run_err(const char *,...); | 289 void run_err(const char *,...); |
290 void verifydir(char *); | 290 void verifydir(char *); |
291 | 291 |
292 struct passwd *pwd; | |
293 uid_t userid; | 292 uid_t userid; |
294 int errs, remin, remout; | 293 int errs, remin, remout; |
295 int pflag, iamremote, iamrecursive, targetshouldbedirectory; | 294 int pflag, iamremote, iamrecursive, targetshouldbedirectory; |
296 | 295 |
297 #define CMDNEEDS 64 | 296 #define CMDNEEDS 64 |
393 default: | 392 default: |
394 usage(); | 393 usage(); |
395 } | 394 } |
396 argc -= optind; | 395 argc -= optind; |
397 argv += optind; | 396 argv += optind; |
398 | |
399 if ((pwd = getpwuid(userid = getuid())) == NULL) | |
400 fatal("unknown user %u", (u_int) userid); | |
401 | 397 |
402 if (!isatty(STDERR_FILENO)) | 398 if (!isatty(STDERR_FILENO)) |
403 showprogress = 0; | 399 showprogress = 0; |
404 | 400 |
405 remin = STDIN_FILENO; | 401 remin = STDIN_FILENO; |
512 if (host) { | 508 if (host) { |
513 *host++ = 0; | 509 *host++ = 0; |
514 host = cleanhostname(host); | 510 host = cleanhostname(host); |
515 suser = argv[i]; | 511 suser = argv[i]; |
516 if (*suser == '\0') | 512 if (*suser == '\0') |
517 suser = pwd->pw_name; | 513 continue; /* pretend there wasn't any @ at all */ |
518 else if (!okname(suser)) | 514 else if (!okname(suser)) |
519 continue; | 515 continue; |
520 addargs(&alist, "-l"); | 516 addargs(&alist, "-l"); |
521 addargs(&alist, "%s", suser); | 517 addargs(&alist, "%s", suser); |
522 } else { | 518 } else { |
580 suser = NULL; | 576 suser = NULL; |
581 } else { | 577 } else { |
582 *host++ = 0; | 578 *host++ = 0; |
583 suser = argv[i]; | 579 suser = argv[i]; |
584 if (*suser == '\0') | 580 if (*suser == '\0') |
585 suser = pwd->pw_name; | 581 suser = NULL; |
586 } | 582 } |
587 host = cleanhostname(host); | 583 host = cleanhostname(host); |
588 len = strlen(src) + CMDNEEDS + 20; | 584 len = strlen(src) + CMDNEEDS + 20; |
589 bp = xmalloc(len); | 585 bp = xmalloc(len); |
590 (void) snprintf(bp, len, "%s -f %s", cmd, src); | 586 (void) snprintf(bp, len, "%s -f %s", cmd, src); |