diff options
author | Colin Watson <cjwatson@debian.org> | 2003-09-01 02:05:26 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2003-09-01 02:05:26 +0000 |
commit | 6d5a72bc1d98a42ba42f082e50a22e911c1d82d3 (patch) | |
tree | 1bf23174bdb6fc71e2846dda0eca195a418484e7 /sftp-server.c | |
parent | 2ee26b431f98cf1dc0e4fb9809ad1e0c879b8c08 (diff) | |
parent | 58657d96514cd6f16d82add8d6f4adbb36765758 (diff) |
Debian release 3.5p1-1.
Diffstat (limited to 'sftp-server.c')
-rw-r--r-- | sftp-server.c | 46 |
1 files changed, 2 insertions, 44 deletions
diff --git a/sftp-server.c b/sftp-server.c index a5c325561..84264693d 100644 --- a/sftp-server.c +++ b/sftp-server.c | |||
@@ -22,7 +22,7 @@ | |||
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | */ | 23 | */ |
24 | #include "includes.h" | 24 | #include "includes.h" |
25 | RCSID("$OpenBSD: sftp-server.c,v 1.37 2002/06/24 17:57:20 deraadt Exp $"); | 25 | RCSID("$OpenBSD: sftp-server.c,v 1.38 2002/09/11 22:41:50 djm Exp $"); |
26 | 26 | ||
27 | #include "buffer.h" | 27 | #include "buffer.h" |
28 | #include "bufaux.h" | 28 | #include "bufaux.h" |
@@ -695,48 +695,6 @@ process_opendir(void) | |||
695 | xfree(path); | 695 | xfree(path); |
696 | } | 696 | } |
697 | 697 | ||
698 | /* | ||
699 | * drwxr-xr-x 5 markus markus 1024 Jan 13 18:39 .ssh | ||
700 | */ | ||
701 | static char * | ||
702 | ls_file(char *name, struct stat *st) | ||
703 | { | ||
704 | int ulen, glen, sz = 0; | ||
705 | struct passwd *pw; | ||
706 | struct group *gr; | ||
707 | struct tm *ltime = localtime(&st->st_mtime); | ||
708 | char *user, *group; | ||
709 | char buf[1024], mode[11+1], tbuf[12+1], ubuf[11+1], gbuf[11+1]; | ||
710 | |||
711 | strmode(st->st_mode, mode); | ||
712 | if ((pw = getpwuid(st->st_uid)) != NULL) { | ||
713 | user = pw->pw_name; | ||
714 | } else { | ||
715 | snprintf(ubuf, sizeof ubuf, "%u", (u_int)st->st_uid); | ||
716 | user = ubuf; | ||
717 | } | ||
718 | if ((gr = getgrgid(st->st_gid)) != NULL) { | ||
719 | group = gr->gr_name; | ||
720 | } else { | ||
721 | snprintf(gbuf, sizeof gbuf, "%u", (u_int)st->st_gid); | ||
722 | group = gbuf; | ||
723 | } | ||
724 | if (ltime != NULL) { | ||
725 | if (time(NULL) - st->st_mtime < (365*24*60*60)/2) | ||
726 | sz = strftime(tbuf, sizeof tbuf, "%b %e %H:%M", ltime); | ||
727 | else | ||
728 | sz = strftime(tbuf, sizeof tbuf, "%b %e %Y", ltime); | ||
729 | } | ||
730 | if (sz == 0) | ||
731 | tbuf[0] = '\0'; | ||
732 | ulen = MAX(strlen(user), 8); | ||
733 | glen = MAX(strlen(group), 8); | ||
734 | snprintf(buf, sizeof buf, "%s %3d %-*s %-*s %8llu %s %s", mode, | ||
735 | st->st_nlink, ulen, user, glen, group, | ||
736 | (u_int64_t)st->st_size, tbuf, name); | ||
737 | return xstrdup(buf); | ||
738 | } | ||
739 | |||
740 | static void | 698 | static void |
741 | process_readdir(void) | 699 | process_readdir(void) |
742 | { | 700 | { |
@@ -772,7 +730,7 @@ process_readdir(void) | |||
772 | continue; | 730 | continue; |
773 | stat_to_attrib(&st, &(stats[count].attrib)); | 731 | stat_to_attrib(&st, &(stats[count].attrib)); |
774 | stats[count].name = xstrdup(dp->d_name); | 732 | stats[count].name = xstrdup(dp->d_name); |
775 | stats[count].long_name = ls_file(dp->d_name, &st); | 733 | stats[count].long_name = ls_file(dp->d_name, &st, 0); |
776 | count++; | 734 | count++; |
777 | /* send up to 100 entries in one message */ | 735 | /* send up to 100 entries in one message */ |
778 | /* XXX check packet size instead */ | 736 | /* XXX check packet size instead */ |