Mercurial > hg > nginx
comparison src/core/ngx_open_file_cache.c @ 4486:a996bb40a0bb
Disable symlinks: cleanups once again.
In collaboration with Ruslan Ermilov.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Tue, 21 Feb 2012 15:01:25 +0000 |
parents | f7d131008e9c |
children | a786c85e8268 |
comparison
equal
deleted
inserted
replaced
4485:f7d131008e9c | 4486:a996bb40a0bb |
---|---|
502 * symlink during openat() or not). | 502 * symlink during openat() or not). |
503 */ | 503 */ |
504 | 504 |
505 fd = ngx_openat_file(at_fd, name, mode, create, access); | 505 fd = ngx_openat_file(at_fd, name, mode, create, access); |
506 | 506 |
507 if (fd == NGX_FILE_ERROR) { | 507 if (fd == NGX_INVALID_FILE) { |
508 return NGX_FILE_ERROR; | 508 return NGX_INVALID_FILE; |
509 } | 509 } |
510 | 510 |
511 if (ngx_file_at_info(at_fd, name, &atfi, AT_SYMLINK_NOFOLLOW) | 511 if (ngx_file_at_info(at_fd, name, &atfi, AT_SYMLINK_NOFOLLOW) |
512 == NGX_FILE_ERROR) | 512 == NGX_FILE_ERROR) |
513 { | 513 { |
580 } | 580 } |
581 | 581 |
582 p = name->data; | 582 p = name->data; |
583 end = p + name->len; | 583 end = p + name->len; |
584 | 584 |
585 at_fd = NGX_AT_FDCWD; | |
586 at_name = *name; | 585 at_name = *name; |
587 | 586 |
588 if (p[0] == '/') { | 587 if (*p == '/') { |
589 at_fd = ngx_openat_file(at_fd, "/", | 588 at_fd = ngx_open_file("/", |
590 NGX_FILE_RDONLY|NGX_FILE_NONBLOCK, | 589 NGX_FILE_RDONLY|NGX_FILE_NONBLOCK, |
591 NGX_FILE_OPEN, 0); | 590 NGX_FILE_OPEN, 0); |
592 | 591 |
593 if (at_fd == NGX_INVALID_FILE) { | 592 if (at_fd == NGX_INVALID_FILE) { |
594 of->err = ngx_errno; | 593 of->err = ngx_errno; |
595 of->failed = ngx_openat_file_n; | 594 of->failed = ngx_openat_file_n; |
596 return NGX_INVALID_FILE; | 595 return NGX_INVALID_FILE; |
597 } | 596 } |
598 | 597 |
599 at_name.len = 1; | 598 at_name.len = 1; |
600 p++; | 599 p++; |
600 | |
601 } else { | |
602 at_fd = NGX_AT_FDCWD; | |
601 } | 603 } |
602 | 604 |
603 for ( ;; ) { | 605 for ( ;; ) { |
604 cp = ngx_strlchr(p, end, '/'); | 606 cp = ngx_strlchr(p, end, '/'); |
605 if (cp == NULL) { | 607 if (cp == NULL) { |
640 p = cp + 1; | 642 p = cp + 1; |
641 at_fd = fd; | 643 at_fd = fd; |
642 at_name.len = cp - at_name.data; | 644 at_name.len = cp - at_name.data; |
643 } | 645 } |
644 | 646 |
645 if (p == end && at_fd != NGX_AT_FDCWD) { | 647 if (p == end) { |
646 | 648 |
647 /* | 649 /* |
648 * If pathname ends with a trailing slash, check if last path | 650 * If pathname ends with a trailing slash, check if last path |
649 * component is a directory; if not, fail with ENOTDIR as per | 651 * component is a directory; if not, fail with ENOTDIR as per |
650 * POSIX. | 652 * POSIX. |