1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-24 07:40:52 +00:00
freebsd/crypto/openssh/openbsd-compat/bsd-statvfs.c
Ed Maste 1323ec5712 ssh: update to OpenSSH v8.9p1
Release notes are available at https://www.openssh.com/txt/release-8.9

Some highlights:

 * ssh(1), sshd(8), ssh-add(1), ssh-agent(1): add a system for
   restricting forwarding and use of keys added to ssh-agent(1)

 * ssh(1), sshd(8): add the sntrup761x25519-sha512@openssh.com hybrid
   ECDH/x25519 + Streamlined NTRU Prime post-quantum KEX to the
   default KEXAlgorithms list (after the ECDH methods but before the
   prime-group DH ones). The next release of OpenSSH is likely to
   make this key exchange the default method.

 * sshd(8), portable OpenSSH only: this release removes in-built
   support for MD5-hashed passwords. If you require these on your
   system then we recommend linking against libxcrypt or similar.

Future deprecation notice
=========================

A near-future release of OpenSSH will switch scp(1) from using the
legacy scp/rcp protocol to using SFTP by default.

Legacy scp/rcp performs wildcard expansion of remote filenames (e.g.
"scp host:* .") through the remote shell. This has the side effect of
requiring double quoting of shell meta-characters in file names
included on scp(1) command-lines, otherwise they could be interpreted
as shell commands on the remote side.

MFC after:	1 month
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2022-04-13 16:00:56 -04:00

94 lines
2.2 KiB
C

/*
* Copyright (c) 2008,2014 Darren Tucker <dtucker@zip.com.au>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "includes.h"
#if !defined(HAVE_STATVFS) || !defined(HAVE_FSTATVFS)
#ifdef HAVE_SYS_MOUNT_H
# include <sys/mount.h>
#endif
#include <errno.h>
#ifndef MNAMELEN
# define MNAMELEN 32
#endif
#ifdef HAVE_STRUCT_STATFS_F_FILES
# define HAVE_STRUCT_STATFS
#endif
#ifdef HAVE_STRUCT_STATFS
static void
copy_statfs_to_statvfs(struct statvfs *to, struct statfs *from)
{
to->f_bsize = from->f_bsize;
to->f_frsize = from->f_bsize; /* no exact equivalent */
to->f_blocks = from->f_blocks;
to->f_bfree = from->f_bfree;
to->f_bavail = from->f_bavail;
to->f_files = from->f_files;
to->f_ffree = from->f_ffree;
to->f_favail = from->f_ffree; /* no exact equivalent */
to->f_fsid = 0; /* XXX fix me */
#ifdef HAVE_STRUCT_STATFS_F_FLAGS
to->f_flag = from->f_flags;
#else
to->f_flag = 0;
#endif
to->f_namemax = MNAMELEN;
}
#endif
# ifndef HAVE_STATVFS
int statvfs(const char *path, struct statvfs *buf)
{
# if defined(HAVE_STATFS) && defined(HAVE_STRUCT_STATFS)
struct statfs fs;
memset(&fs, 0, sizeof(fs));
if (statfs(path, &fs) == -1)
return -1;
copy_statfs_to_statvfs(buf, &fs);
return 0;
# else
errno = ENOSYS;
return -1;
# endif
}
# endif
# ifndef HAVE_FSTATVFS
int fstatvfs(int fd, struct statvfs *buf)
{
# if defined(HAVE_FSTATFS) && defined(HAVE_STRUCT_STATFS)
struct statfs fs;
memset(&fs, 0, sizeof(fs));
if (fstatfs(fd, &fs) == -1)
return -1;
copy_statfs_to_statvfs(buf, &fs);
return 0;
# else
errno = ENOSYS;
return -1;
# endif
}
# endif
#endif