summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2008-06-09 03:32:29 +1000
committerDarren Tucker <dtucker@zip.com.au>2008-06-09 03:32:29 +1000
commit598eaa6c0c36c3169963c7e6505d53b4073590f5 (patch)
tree52872f9bfe82fd5a3e1b1a059bd063351bfbadd7
parent294b84183265a9be32971fce856e578160e1a825 (diff)
- (dtucker) [configure.ac defines.h sftp-client.c sftp-server.c sftp.c
openbsd-compat/Makefile.in openbsd-compat/openbsd-compat.h openbsd-compat/bsd-statvfs.{c,h}] Add a null implementation of statvfs and fstatvfs and remove #defines around statvfs code. ok djm@
-rw-r--r--ChangeLog8
-rw-r--r--configure.ac17
-rw-r--r--defines.h6
-rw-r--r--openbsd-compat/Makefile.in4
-rw-r--r--openbsd-compat/bsd-statvfs.c37
-rw-r--r--openbsd-compat/bsd-statvfs.h68
-rw-r--r--openbsd-compat/openbsd-compat.h3
-rw-r--r--sftp-client.c4
-rw-r--r--sftp-server.c8
-rw-r--r--sftp.c5
10 files changed, 132 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index be3e104ee..9b3e1d6d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
120080608
2 - (dtucker) [configure.ac defines.h sftp-client.c sftp-server.c sftp.c
3 openbsd-compat/Makefile.in openbsd-compat/openbsd-compat.h
4 openbsd-compat/bsd-statvfs.{c,h}] Add a null implementation of statvfs and
5 fstatvfs and remove #defines around statvfs code. ok djm@
6
120080607 720080607
2 - (dtucker) [mux.c] Include paths.h inside ifdef HAVE_PATHS_H. 8 - (dtucker) [mux.c] Include paths.h inside ifdef HAVE_PATHS_H.
3 - (dtucker) [configure.ac defines.h sftp-client.c sftp-server.c sftp.c] 9 - (dtucker) [configure.ac defines.h sftp-client.c sftp-server.c sftp.c]
@@ -4054,4 +4060,4 @@
4054 OpenServer 6 and add osr5bigcrypt support so when someone migrates 4060 OpenServer 6 and add osr5bigcrypt support so when someone migrates
4055 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 4061 passwords between UnixWare and OpenServer they will still work. OK dtucker@
4056 4062
4057$Id: ChangeLog,v 1.4942 2008/06/08 02:55:32 dtucker Exp $ 4063$Id: ChangeLog,v 1.4943 2008/06/08 17:32:29 dtucker Exp $
diff --git a/configure.ac b/configure.ac
index 3005e21b5..4f3ec2a20 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
1# $Id: configure.ac,v 1.400 2008/06/07 23:25:28 dtucker Exp $ 1# $Id: configure.ac,v 1.401 2008/06/08 17:32:29 dtucker Exp $
2# 2#
3# Copyright (c) 1999-2004 Damien Miller 3# Copyright (c) 1999-2004 Damien Miller
4# 4#
@@ -15,7 +15,7 @@
15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 16
17AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org) 17AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org)
18AC_REVISION($Revision: 1.400 $) 18AC_REVISION($Revision: 1.401 $)
19AC_CONFIG_SRCDIR([ssh.c]) 19AC_CONFIG_SRCDIR([ssh.c])
20 20
21AC_CONFIG_HEADER(config.h) 21AC_CONFIG_HEADER(config.h)
@@ -1305,6 +1305,7 @@ AC_CHECK_FUNCS( \
1305 fchmod \ 1305 fchmod \
1306 fchown \ 1306 fchown \
1307 freeaddrinfo \ 1307 freeaddrinfo \
1308 fstatvfs \
1308 futimes \ 1309 futimes \
1309 getaddrinfo \ 1310 getaddrinfo \
1310 getcwd \ 1311 getcwd \
@@ -2651,6 +2652,18 @@ fi
2651TYPE_SOCKLEN_T 2652TYPE_SOCKLEN_T
2652 2653
2653AC_CHECK_TYPES(sig_atomic_t,,,[#include <signal.h>]) 2654AC_CHECK_TYPES(sig_atomic_t,,,[#include <signal.h>])
2655AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t],,,[
2656#include <sys/types.h>
2657#ifdef HAVE_SYS_BITYPES_H
2658#include <sys/bitypes.h>
2659#endif
2660#ifdef HAVE_SYS_STATFS_H
2661#include <sys/statfs.h>
2662#endif
2663#ifdef HAVE_SYS_STATVFS_H
2664#include <sys/statvfs.h>
2665#endif
2666])
2654 2667
2655AC_CHECK_TYPES(in_addr_t,,, 2668AC_CHECK_TYPES(in_addr_t,,,
2656[#include <sys/types.h> 2669[#include <sys/types.h>
diff --git a/defines.h b/defines.h
index a2cc28d98..7bb3a55e8 100644
--- a/defines.h
+++ b/defines.h
@@ -25,7 +25,7 @@
25#ifndef _DEFINES_H 25#ifndef _DEFINES_H
26#define _DEFINES_H 26#define _DEFINES_H
27 27
28/* $Id: defines.h,v 1.147 2008/06/07 23:25:28 dtucker Exp $ */ 28/* $Id: defines.h,v 1.148 2008/06/08 17:32:29 dtucker Exp $ */
29 29
30 30
31/* Constants */ 31/* Constants */
@@ -567,10 +567,6 @@ struct winsize {
567# define CUSTOM_SSH_AUDIT_EVENTS 567# define CUSTOM_SSH_AUDIT_EVENTS
568#endif 568#endif
569 569
570#if defined(HAVE_STATVFS)
571# define USE_STATVFS
572#endif
573
574#if !defined(HAVE___func__) && defined(HAVE___FUNCTION__) 570#if !defined(HAVE___func__) && defined(HAVE___FUNCTION__)
575# define __func__ __FUNCTION__ 571# define __func__ __FUNCTION__
576#elif !defined(HAVE___func__) 572#elif !defined(HAVE___func__)
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in
index d1ec47b6e..a60e5a68d 100644
--- a/openbsd-compat/Makefile.in
+++ b/openbsd-compat/Makefile.in
@@ -1,4 +1,4 @@
1# $Id: Makefile.in,v 1.42 2008/05/19 22:57:08 djm Exp $ 1# $Id: Makefile.in,v 1.43 2008/06/08 17:32:29 dtucker Exp $
2 2
3sysconfdir=@sysconfdir@ 3sysconfdir=@sysconfdir@
4piddir=@piddir@ 4piddir=@piddir@
@@ -18,7 +18,7 @@ LDFLAGS=-L. @LDFLAGS@
18 18
19OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o fmt_scaled.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sha2.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o strtonum.o strtoll.o strtoul.o vis.o 19OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o fmt_scaled.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sha2.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o strtonum.o strtoll.o strtoul.o vis.o
20 20
21COMPAT=bsd-arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o 21COMPAT=bsd-arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o
22 22
23PORTS=port-aix.o port-irix.o port-linux.o port-solaris.o port-tun.o port-uw.o 23PORTS=port-aix.o port-irix.o port-linux.o port-solaris.o port-tun.o port-uw.o
24 24
diff --git a/openbsd-compat/bsd-statvfs.c b/openbsd-compat/bsd-statvfs.c
new file mode 100644
index 000000000..844d5b464
--- /dev/null
+++ b/openbsd-compat/bsd-statvfs.c
@@ -0,0 +1,37 @@
1/* $Id: bsd-statvfs.c,v 1.1 2008/06/08 17:32:29 dtucker Exp $ */
2
3/*
4 * Copyright (c) 2008 Darren Tucker <dtucker@zip.com.au>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include "includes.h"
20
21#include <errno.h>
22
23#ifndef HAVE_STATVFS
24int statvfs(const char *path, struct statvfs *buf)
25{
26 errno = ENOSYS;
27 return -1;
28}
29#endif
30
31#ifndef HAVE_FSTATVFS
32int fstatvfs(int fd, struct statvfs *buf)
33{
34 errno = ENOSYS;
35 return -1;
36}
37#endif
diff --git a/openbsd-compat/bsd-statvfs.h b/openbsd-compat/bsd-statvfs.h
new file mode 100644
index 000000000..da215ffc6
--- /dev/null
+++ b/openbsd-compat/bsd-statvfs.h
@@ -0,0 +1,68 @@
1/* $Id: bsd-statvfs.h,v 1.1 2008/06/08 17:32:29 dtucker Exp $ */
2
3/*
4 * Copyright (c) 2008 Darren Tucker <dtucker@zip.com.au>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include "includes.h"
20
21#include <sys/types.h>
22
23#ifdef HAVE_SYS_STATFS_H
24#include <sys/statfs.h>
25#endif
26
27#ifndef HAVE_STATVFS
28
29#ifndef HAVE_FSBLKCNT_T
30typedef unsigned long fsblkcnt_t;
31#endif
32#ifndef HAVE_FSFILCNT_T
33typedef unsigned long fsfilcnt_t;
34#endif
35
36#ifndef ST_RDONLY
37#define ST_RDONLY 1
38#endif
39#ifndef ST_NOSUID
40#define ST_NOSUID 2
41#endif
42
43 /* as defined in IEEE Std 1003.1, 2004 Edition */
44struct statvfs {
45 unsigned long f_bsize; /* File system block size. */
46 unsigned long f_frsize; /* Fundamental file system block size. */
47 fsblkcnt_t f_blocks; /* Total number of blocks on file system in */
48 /* units of f_frsize. */
49 fsblkcnt_t f_bfree; /* Total number of free blocks. */
50 fsblkcnt_t f_bavail; /* Number of free blocks available to */
51 /* non-privileged process. */
52 fsfilcnt_t f_files; /* Total number of file serial numbers. */
53 fsfilcnt_t f_ffree; /* Total number of free file serial numbers. */
54 fsfilcnt_t f_favail; /* Number of file serial numbers available to */
55 /* non-privileged process. */
56 unsigned long f_fsid; /* File system ID. */
57 unsigned long f_flag; /* BBit mask of f_flag values. */
58 unsigned long f_namemax;/* Maximum filename length. */
59};
60#endif
61
62#ifndef HAVE_STATVFS
63int statvfs(const char *, struct statvfs *);
64#endif
65
66#ifndef HAVE_FSTATVFS
67int fstatvfs(int, struct statvfs *);
68#endif
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h
index 0b7d979e0..50c6d990b 100644
--- a/openbsd-compat/openbsd-compat.h
+++ b/openbsd-compat/openbsd-compat.h
@@ -1,4 +1,4 @@
1/* $Id: openbsd-compat.h,v 1.45 2008/05/19 22:57:08 djm Exp $ */ 1/* $Id: openbsd-compat.h,v 1.46 2008/06/08 17:32:29 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999-2003 Damien Miller. All rights reserved. 4 * Copyright (c) 1999-2003 Damien Miller. All rights reserved.
@@ -144,6 +144,7 @@ int writev(int, struct iovec *, int);
144 144
145/* Home grown routines */ 145/* Home grown routines */
146#include "bsd-misc.h" 146#include "bsd-misc.h"
147#include "bsd-statvfs.h"
147#include "bsd-waitpid.h" 148#include "bsd-waitpid.h"
148#include "bsd-poll.h" 149#include "bsd-poll.h"
149 150
diff --git a/sftp-client.c b/sftp-client.c
index 512a8ad4b..1fda576b4 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -243,7 +243,6 @@ get_decode_stat(int fd, u_int expected_id, int quiet)
243 return(a); 243 return(a);
244} 244}
245 245
246#ifdef USE_STATVFS
247static int 246static int
248get_decode_statvfs(int fd, struct statvfs *st, u_int expected_id, int quiet) 247get_decode_statvfs(int fd, struct statvfs *st, u_int expected_id, int quiet)
249{ 248{
@@ -293,7 +292,6 @@ get_decode_statvfs(int fd, struct statvfs *st, u_int expected_id, int quiet)
293 292
294 return 0; 293 return 0;
295} 294}
296#endif
297 295
298struct sftp_conn * 296struct sftp_conn *
299do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests) 297do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests)
@@ -813,7 +811,6 @@ do_readlink(struct sftp_conn *conn, char *path)
813} 811}
814#endif 812#endif
815 813
816#ifdef USE_STATVFS
817int 814int
818do_statvfs(struct sftp_conn *conn, const char *path, struct statvfs *st, 815do_statvfs(struct sftp_conn *conn, const char *path, struct statvfs *st,
819 int quiet) 816 int quiet)
@@ -839,7 +836,6 @@ do_statvfs(struct sftp_conn *conn, const char *path, struct statvfs *st,
839 836
840 return get_decode_statvfs(conn->fd_in, st, id, quiet); 837 return get_decode_statvfs(conn->fd_in, st, id, quiet);
841} 838}
842#endif
843 839
844#ifdef notyet 840#ifdef notyet
845int 841int
diff --git a/sftp-server.c b/sftp-server.c
index 2c25df9de..9c3128347 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -481,7 +481,6 @@ send_attrib(u_int32_t id, const Attrib *a)
481 buffer_free(&msg); 481 buffer_free(&msg);
482} 482}
483 483
484#ifdef USE_STATVFS
485static void 484static void
486send_statvfs(u_int32_t id, struct statvfs *st) 485send_statvfs(u_int32_t id, struct statvfs *st)
487{ 486{
@@ -508,7 +507,6 @@ send_statvfs(u_int32_t id, struct statvfs *st)
508 send_msg(&msg); 507 send_msg(&msg);
509 buffer_free(&msg); 508 buffer_free(&msg);
510} 509}
511#endif
512 510
513/* parse incoming */ 511/* parse incoming */
514 512
@@ -525,14 +523,12 @@ process_init(void)
525 /* POSIX rename extension */ 523 /* POSIX rename extension */
526 buffer_put_cstring(&msg, "posix-rename@openssh.com"); 524 buffer_put_cstring(&msg, "posix-rename@openssh.com");
527 buffer_put_cstring(&msg, "1"); /* version */ 525 buffer_put_cstring(&msg, "1"); /* version */
528#ifdef USEE_STATVFS
529 /* statvfs extension */ 526 /* statvfs extension */
530 buffer_put_cstring(&msg, "statvfs@openssh.com"); 527 buffer_put_cstring(&msg, "statvfs@openssh.com");
531 buffer_put_cstring(&msg, "2"); /* version */ 528 buffer_put_cstring(&msg, "2"); /* version */
532 /* fstatvfs extension */ 529 /* fstatvfs extension */
533 buffer_put_cstring(&msg, "fstatvfs@openssh.com"); 530 buffer_put_cstring(&msg, "fstatvfs@openssh.com");
534 buffer_put_cstring(&msg, "2"); /* version */ 531 buffer_put_cstring(&msg, "2"); /* version */
535#endif
536 send_msg(&msg); 532 send_msg(&msg);
537 buffer_free(&msg); 533 buffer_free(&msg);
538} 534}
@@ -1142,7 +1138,6 @@ process_extended_posix_rename(u_int32_t id)
1142 xfree(newpath); 1138 xfree(newpath);
1143} 1139}
1144 1140
1145#ifdef USE_STATVFS
1146static void 1141static void
1147process_extended_statvfs(u_int32_t id) 1142process_extended_statvfs(u_int32_t id)
1148{ 1143{
@@ -1178,7 +1173,6 @@ process_extended_fstatvfs(u_int32_t id)
1178 else 1173 else
1179 send_statvfs(id, &st); 1174 send_statvfs(id, &st);
1180} 1175}
1181#endif
1182 1176
1183static void 1177static void
1184process_extended(void) 1178process_extended(void)
@@ -1190,12 +1184,10 @@ process_extended(void)
1190 request = get_string(NULL); 1184 request = get_string(NULL);
1191 if (strcmp(request, "posix-rename@openssh.com") == 0) 1185 if (strcmp(request, "posix-rename@openssh.com") == 0)
1192 process_extended_posix_rename(id); 1186 process_extended_posix_rename(id);
1193#ifdef USE_STATVFS
1194 else if (strcmp(request, "statvfs@openssh.com") == 0) 1187 else if (strcmp(request, "statvfs@openssh.com") == 0)
1195 process_extended_statvfs(id); 1188 process_extended_statvfs(id);
1196 else if (strcmp(request, "fstatvfs@openssh.com") == 0) 1189 else if (strcmp(request, "fstatvfs@openssh.com") == 0)
1197 process_extended_fstatvfs(id); 1190 process_extended_fstatvfs(id);
1198#endif
1199 else 1191 else
1200 send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */ 1192 send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */
1201 xfree(request); 1193 xfree(request);
diff --git a/sftp.c b/sftp.c
index c5c3b1443..50ac03798 100644
--- a/sftp.c
+++ b/sftp.c
@@ -842,7 +842,6 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
842static int 842static int
843do_df(struct sftp_conn *conn, char *path, int hflag, int iflag) 843do_df(struct sftp_conn *conn, char *path, int hflag, int iflag)
844{ 844{
845#ifdef USE_STATVFS
846 struct statvfs st; 845 struct statvfs st;
847 char s_used[FMT_SCALED_STRSIZE]; 846 char s_used[FMT_SCALED_STRSIZE];
848 char s_avail[FMT_SCALED_STRSIZE]; 847 char s_avail[FMT_SCALED_STRSIZE];
@@ -888,10 +887,6 @@ do_df(struct sftp_conn *conn, char *path, int hflag, int iflag)
888 st.f_blocks)); 887 st.f_blocks));
889 } 888 }
890 return 0; 889 return 0;
891#else
892 error("client does not support statvfs extension");
893 return -1;
894#endif
895} 890}
896 891
897/* 892/*