diff options
Diffstat (limited to 'sys')
40 files changed, 278 insertions, 89 deletions
diff --git a/sys/arch/alpha/stand/boot/filesystem.c b/sys/arch/alpha/stand/boot/filesystem.c index 25be97d2685..eeb7e1d71ef 100644 --- a/sys/arch/alpha/stand/boot/filesystem.c +++ b/sys/arch/alpha/stand/boot/filesystem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filesystem.c,v 1.4 1997/05/05 06:01:52 millert Exp $ */ +/* $OpenBSD: filesystem.c,v 1.5 2019/08/03 15:22:19 deraadt Exp $ */ /* $NetBSD: filesystem.c,v 1.3 1997/04/06 08:40:35 cgd Exp $ */ /* @@ -39,8 +39,10 @@ #include <lib/libsa/cd9660.h> struct fs_ops file_system[] = { - { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }, - { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek, cd9660_stat }, + { ufs_open, ufs_close, ufs_read, ufs_write, + ufs_seek, ufs_stat, ufs_readdir, ufs_fchmod }, + { cd9660_open, cd9660_close, cd9660_read, cd9660_write, + cd9660_seek, cd9660_stat }, }; int nfsys = sizeof(file_system)/sizeof(struct fs_ops); diff --git a/sys/arch/amd64/stand/boot/Makefile b/sys/arch/amd64/stand/boot/Makefile index a96ae53fb18..b2b6d03abb8 100644 --- a/sys/arch/amd64/stand/boot/Makefile +++ b/sys/arch/amd64/stand/boot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.41 2019/05/15 06:52:33 mlarkin Exp $ +# $OpenBSD: Makefile,v 1.42 2019/08/03 15:22:19 deraadt Exp $ COPTS?= MAN?= boot.8 @@ -35,8 +35,8 @@ SRCS+= softraid_amd64.c SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c printf.c \ putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \ strtol.c strtoll.c -SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ - lseek.c open.c read.c readdir.c stat.c +SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \ + fstat.c lseek.c open.c read.c readdir.c stat.c SRCS+= elf32.c elf64.c loadfile.c SRCS+= ufs.c .if ${SOFTRAID:L} == "yes" diff --git a/sys/arch/amd64/stand/boot/conf.c b/sys/arch/amd64/stand/boot/conf.c index 3f043d2e75b..bb801317c5a 100644 --- a/sys/arch/amd64/stand/boot/conf.c +++ b/sys/arch/amd64/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.47 2019/06/08 02:52:20 jsg Exp $ */ +/* $OpenBSD: conf.c,v 1.48 2019/08/03 15:22:19 deraadt Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -63,7 +63,7 @@ int nibprobes = nitems(probe_list); struct fs_ops file_system[] = { { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir, ufs_fchmod }, #ifdef notdef { fat_open, fat_close, fat_read, fat_write, fat_seek, fat_stat, fat_readdir }, diff --git a/sys/arch/amd64/stand/cdboot/Makefile b/sys/arch/amd64/stand/cdboot/Makefile index fd09735657e..eea6875dd0a 100644 --- a/sys/arch/amd64/stand/cdboot/Makefile +++ b/sys/arch/amd64/stand/cdboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.36 2019/05/15 06:52:33 mlarkin Exp $ +# $OpenBSD: Makefile,v 1.37 2019/08/03 15:22:19 deraadt Exp $ MAN= cdboot.8 @@ -28,8 +28,8 @@ SRCS+= cmd.c vars.c bootarg.c SRCS+= alloc.c exit.c getchar.c putchar.c strcmp.c strlen.c \ strncmp.c memcmp.c memcpy.c memmove.c memset.c printf.c snprintf.c \ strerror.c strncpy.c strtol.c strtoll.c ctime.c strlcpy.c -SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fstat.c lseek.c \ - open.c read.c stat.c cread.c readdir.c cons.c loadfile.c \ +SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fchmod.c fstat.c \ + lseek.c open.c read.c stat.c cread.c readdir.c cons.c loadfile.c \ elf32.c elf64.c SRCS+= ufs.c cd9660.c SRCS+= aes_xts.c bcrypt_pbkdf.c blowfish.c explicit_bzero.c hmac_sha1.c \ diff --git a/sys/arch/amd64/stand/cdboot/conf.c b/sys/arch/amd64/stand/cdboot/conf.c index 9731de7c436..6baa7c34b08 100644 --- a/sys/arch/amd64/stand/cdboot/conf.c +++ b/sys/arch/amd64/stand/cdboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.40 2019/05/15 06:52:33 mlarkin Exp $ */ +/* $OpenBSD: conf.c,v 1.41 2019/08/03 15:22:19 deraadt Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -65,7 +65,7 @@ struct fs_ops file_system[] = { { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek, cd9660_stat, cd9660_readdir }, { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir, ufs_fchmod }, #ifdef notdef { tftp_open, tftp_close, tftp_read, tftp_write, tftp_seek, tftp_stat, tftp_readdir }, diff --git a/sys/arch/amd64/stand/efi32/Makefile.common b/sys/arch/amd64/stand/efi32/Makefile.common index 010b5252e49..d8b7e795ade 100644 --- a/sys/arch/amd64/stand/efi32/Makefile.common +++ b/sys/arch/amd64/stand/efi32/Makefile.common @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.common,v 1.1 2019/05/11 02:33:34 mlarkin Exp $ +# $OpenBSD: Makefile.common,v 1.2 2019/08/03 15:22:19 deraadt Exp $ S= ${.CURDIR}/../../../../.. SADIR= ${.CURDIR}/../.. @@ -35,8 +35,8 @@ SRCS+= boot.c bootarg.c cmd.c vars.c SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c printf.c \ putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \ strtol.c strtoll.c -SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ - lseek.c open.c read.c readdir.c stat.c +SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \ + fstat.c lseek.c open.c read.c readdir.c stat.c SRCS+= ufs.c cd9660.c .if ${SOFTRAID:L} == "yes" SRCS+= aes_xts.c bcrypt_pbkdf.c blowfish.c explicit_bzero.c hmac_sha1.c \ diff --git a/sys/arch/amd64/stand/efi32/conf.c b/sys/arch/amd64/stand/efi32/conf.c index 6791259ea38..75b84f16be6 100644 --- a/sys/arch/amd64/stand/efi32/conf.c +++ b/sys/arch/amd64/stand/efi32/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.1 2019/05/11 02:33:34 mlarkin Exp $ */ +/* $OpenBSD: conf.c,v 1.2 2019/08/03 15:22:20 deraadt Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -66,7 +66,7 @@ struct fs_ops file_system[] = { { tftp_open, tftp_close, tftp_read, tftp_write, tftp_seek, tftp_stat, tftp_readdir }, { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir ufs_fchmod }, { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek, cd9660_stat, cd9660_readdir }, #ifdef notdef diff --git a/sys/arch/amd64/stand/efi64/Makefile.common b/sys/arch/amd64/stand/efi64/Makefile.common index 7d7f06ed608..64052ba2b20 100644 --- a/sys/arch/amd64/stand/efi64/Makefile.common +++ b/sys/arch/amd64/stand/efi64/Makefile.common @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.common,v 1.1 2019/05/11 02:36:10 mlarkin Exp $ +# $OpenBSD: Makefile.common,v 1.2 2019/08/03 15:22:20 deraadt Exp $ S= ${.CURDIR}/../../../../.. SADIR= ${.CURDIR}/../.. @@ -35,8 +35,8 @@ SRCS+= boot.c bootarg.c cmd.c vars.c SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c printf.c \ putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \ strtol.c strtoll.c -SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ - lseek.c open.c read.c readdir.c stat.c +SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \ + fstat.c lseek.c open.c read.c readdir.c stat.c SRCS+= ufs.c cd9660.c .if ${SOFTRAID:L} == "yes" SRCS+= aes_xts.c bcrypt_pbkdf.c blowfish.c explicit_bzero.c hmac_sha1.c \ diff --git a/sys/arch/amd64/stand/efi64/conf.c b/sys/arch/amd64/stand/efi64/conf.c index f50a6384646..7f4d23470d1 100644 --- a/sys/arch/amd64/stand/efi64/conf.c +++ b/sys/arch/amd64/stand/efi64/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.1 2019/05/11 02:36:10 mlarkin Exp $ */ +/* $OpenBSD: conf.c,v 1.2 2019/08/03 15:22:20 deraadt Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -66,7 +66,7 @@ struct fs_ops file_system[] = { { tftp_open, tftp_close, tftp_read, tftp_write, tftp_seek, tftp_stat, tftp_readdir }, { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir, ufs_fchmod }, { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek, cd9660_stat, cd9660_readdir }, #ifdef notdef diff --git a/sys/arch/amd64/stand/efiboot/Makefile.common b/sys/arch/amd64/stand/efiboot/Makefile.common index 788e721d958..b45c3f6b2db 100644 --- a/sys/arch/amd64/stand/efiboot/Makefile.common +++ b/sys/arch/amd64/stand/efiboot/Makefile.common @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.common,v 1.16 2019/05/10 21:20:42 mlarkin Exp $ +# $OpenBSD: Makefile.common,v 1.17 2019/08/03 15:22:20 deraadt Exp $ S= ${.CURDIR}/../../../../.. SADIR= ${.CURDIR}/../.. @@ -35,8 +35,8 @@ SRCS+= boot.c bootarg.c cmd.c vars.c SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c printf.c \ putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \ strtol.c strtoll.c -SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ - lseek.c open.c read.c readdir.c stat.c +SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c \ + fchmod.c fstat.c lseek.c open.c read.c readdir.c stat.c SRCS+= ufs.c cd9660.c .if ${SOFTRAID:L} == "yes" SRCS+= aes_xts.c bcrypt_pbkdf.c blowfish.c explicit_bzero.c hmac_sha1.c \ diff --git a/sys/arch/amd64/stand/efiboot/conf.c b/sys/arch/amd64/stand/efiboot/conf.c index 5a4caba2a52..9a067296343 100644 --- a/sys/arch/amd64/stand/efiboot/conf.c +++ b/sys/arch/amd64/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.20 2019/05/05 19:17:03 kettenis Exp $ */ +/* $OpenBSD: conf.c,v 1.21 2019/08/03 15:22:20 deraadt Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -66,7 +66,7 @@ struct fs_ops file_system[] = { { tftp_open, tftp_close, tftp_read, tftp_write, tftp_seek, tftp_stat, tftp_readdir }, { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir, ufs_fchmod }, { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek, cd9660_stat, cd9660_readdir }, #ifdef notdef diff --git a/sys/arch/amd64/stand/pxeboot/Makefile b/sys/arch/amd64/stand/pxeboot/Makefile index 12948210cee..aba27c94e2f 100644 --- a/sys/arch/amd64/stand/pxeboot/Makefile +++ b/sys/arch/amd64/stand/pxeboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.34 2019/05/15 06:52:33 mlarkin Exp $ +# $OpenBSD: Makefile,v 1.35 2019/08/03 15:22:20 deraadt Exp $ MAN= pxeboot.8 @@ -34,9 +34,9 @@ SRCS+= alloc.c exit.c getchar.c getfile.c getln.c globals.c putchar.c \ SRCS+= aes_xts.c bcrypt_pbkdf.c blowfish.c explicit_bzero.c hmac_sha1.c \ pkcs5_pbkdf2.c rijndael.c sha1.c sha2.c softraid.c -SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fstat.c ioctl.c lseek.c \ - read.c stat.c write.c cread.c readdir.c cons.c loadfile.c \ - elf32.c elf64.c +SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fchmod.c fstat.c \ + ioctl.c lseek.c read.c stat.c write.c cread.c readdir.c cons.c \ + loadfile.c elf32.c elf64.c SRCS+= ether.c net.c netif.c rpc.c SRCS+= bootp.c bootparam.c SRCS+= ufs.c nfs.c tftp.c diff --git a/sys/arch/amd64/stand/pxeboot/conf.c b/sys/arch/amd64/stand/pxeboot/conf.c index bef9e5f520f..33bfc868330 100644 --- a/sys/arch/amd64/stand/pxeboot/conf.c +++ b/sys/arch/amd64/stand/pxeboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.44 2019/05/15 06:52:33 mlarkin Exp $ */ +/* $OpenBSD: conf.c,v 1.45 2019/08/03 15:22:20 deraadt Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -75,7 +75,7 @@ int nfsname = nitems(fs_name); struct fs_ops file_system[] = { { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir, ufs_fchmod }, { tftp_open, tftp_close, tftp_read, tftp_write, tftp_seek, tftp_stat, tftp_readdir }, { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, diff --git a/sys/arch/arm64/stand/efiboot/Makefile b/sys/arch/arm64/stand/efiboot/Makefile index 47cb5d488e7..09b2e05928c 100644 --- a/sys/arch/arm64/stand/efiboot/Makefile +++ b/sys/arch/arm64/stand/efiboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.7 2019/01/31 14:35:06 patrick Exp $ +# $OpenBSD: Makefile,v 1.8 2019/08/03 15:22:20 deraadt Exp $ NOMAN= # @@ -27,8 +27,8 @@ SRCS+= boot.c cmd.c vars.c SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c \ printf.c putchar.c snprintf.c strchr.c strcmp.c strerror.c strncmp.c \ strncpy.c strtol.c -SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ - lseek.c open.c read.c readdir.c stat.c +SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \ + fstat.c lseek.c open.c read.c readdir.c stat.c SRCS+= loadfile.c SRCS+= ufs.c SRCS+= arp.c ether.c globals.c in_cksum.c net.c netif.c netudp.c tftp.c diff --git a/sys/arch/arm64/stand/efiboot/conf.c b/sys/arch/arm64/stand/efiboot/conf.c index aa659b769d8..d32b2b080ce 100644 --- a/sys/arch/arm64/stand/efiboot/conf.c +++ b/sys/arch/arm64/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.19 2019/04/10 04:19:31 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.20 2019/08/03 15:22:20 deraadt Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -54,7 +54,7 @@ struct fs_ops file_system[] = { { efitftp_open,tftp_close, tftp_read, tftp_write, tftp_seek, tftp_stat, tftp_readdir }, { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir, ufs_fchmod }, }; int nfsys = nitems(file_system); diff --git a/sys/arch/armv7/stand/efiboot/Makefile b/sys/arch/armv7/stand/efiboot/Makefile index 3758b56ea10..9b054df13a8 100644 --- a/sys/arch/armv7/stand/efiboot/Makefile +++ b/sys/arch/armv7/stand/efiboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.11 2018/06/23 22:13:50 kettenis Exp $ +# $OpenBSD: Makefile,v 1.12 2019/08/03 15:22:20 deraadt Exp $ NOMAN= # @@ -27,8 +27,8 @@ SRCS+= boot.c cmd.c vars.c SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c \ printf.c putchar.c snprintf.c strchr.c strcmp.c strerror.c strncmp.c \ strncpy.c strtol.c -SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ - lseek.c open.c read.c readdir.c stat.c +SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \ + fstat.c lseek.c open.c read.c readdir.c stat.c SRCS+= loadfile.c SRCS+= ufs.c SRCS+= arp.c ether.c globals.c in_cksum.c net.c netif.c netudp.c tftp.c diff --git a/sys/arch/armv7/stand/efiboot/conf.c b/sys/arch/armv7/stand/efiboot/conf.c index 2fd31d00912..f7c3d5d7578 100644 --- a/sys/arch/armv7/stand/efiboot/conf.c +++ b/sys/arch/armv7/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.16 2019/07/22 11:51:30 kettenis Exp $ */ +/* $OpenBSD: conf.c,v 1.17 2019/08/03 15:22:20 deraadt Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -45,7 +45,7 @@ struct fs_ops file_system[] = { { efitftp_open,tftp_close, tftp_read, tftp_write, tftp_seek, tftp_stat, tftp_readdir }, { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir, ufs_fchmod }, }; int nfsys = nitems(file_system); diff --git a/sys/arch/hppa/stand/boot/conf.c b/sys/arch/hppa/stand/boot/conf.c index 55d8bc799ae..e6a46dec2ac 100644 --- a/sys/arch/hppa/stand/boot/conf.c +++ b/sys/arch/hppa/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.31 2019/04/10 04:19:32 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.32 2019/08/03 15:22:20 deraadt Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -37,7 +37,7 @@ int debug = 0; struct fs_ops file_system[] = { { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir, ufs_fchmod }, { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek, cd9660_stat, cd9660_readdir }, { lif_open, lif_close, lif_read, lif_write, lif_seek, diff --git a/sys/arch/hppa/stand/libsa/Makefile b/sys/arch/hppa/stand/libsa/Makefile index 58cc74111a4..99ba3d5867e 100644 --- a/sys/arch/hppa/stand/libsa/Makefile +++ b/sys/arch/hppa/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.20 2015/11/16 19:33:52 miod Exp $ +# $OpenBSD: Makefile,v 1.21 2019/08/03 15:22:20 deraadt Exp $ .include "${.CURDIR}/../Makefile.inc" @@ -24,8 +24,8 @@ SRCS+= alloc.c exit.c getfile.c getln.c getchar.c globals.c \ printf.c putchar.c strerror.c strtol.c strchr.c ctime.c snprintf.c # io routines -SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fstat.c ioctl.c lseek.c \ - open.c read.c stat.c write.c cread.c readdir.c cons.c +SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fchmod.c fstat.c \ + ioctl.c lseek.c open.c read.c stat.c write.c cread.c readdir.c cons.c # boot filesystems SRCS+= ufs.c cd9660.c diff --git a/sys/arch/i386/stand/boot/Makefile b/sys/arch/i386/stand/boot/Makefile index f087b3ee62e..4b7f7ab71c2 100644 --- a/sys/arch/i386/stand/boot/Makefile +++ b/sys/arch/i386/stand/boot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.68 2019/04/20 22:59:03 deraadt Exp $ +# $OpenBSD: Makefile,v 1.69 2019/08/03 15:22:20 deraadt Exp $ COPTS?= MAN?= boot.8 @@ -39,8 +39,8 @@ SRCS+= softraid_i386.c SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c printf.c \ putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \ strtol.c strtoll.c -SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ - lseek.c open.c read.c readdir.c stat.c +SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \ + fstat.c lseek.c open.c read.c readdir.c stat.c SRCS+= elf32.c elf64.c loadfile.c SRCS+= ufs.c .if ${SOFTRAID:L} == "yes" diff --git a/sys/arch/i386/stand/boot/conf.c b/sys/arch/i386/stand/boot/conf.c index 0e6cccc3741..37a8f006347 100644 --- a/sys/arch/i386/stand/boot/conf.c +++ b/sys/arch/i386/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.69 2019/06/08 02:52:20 jsg Exp $ */ +/* $OpenBSD: conf.c,v 1.70 2019/08/03 15:22:20 deraadt Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -65,7 +65,7 @@ int nibprobes = nitems(probe_list); struct fs_ops file_system[] = { { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir, ufs_fchmod }, #ifdef notdef { fat_open, fat_close, fat_read, fat_write, fat_seek, fat_stat, fat_readdir }, diff --git a/sys/arch/i386/stand/cdboot/Makefile b/sys/arch/i386/stand/cdboot/Makefile index fe157e400bd..064803c8d95 100644 --- a/sys/arch/i386/stand/cdboot/Makefile +++ b/sys/arch/i386/stand/cdboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.32 2019/04/20 22:59:03 deraadt Exp $ +# $OpenBSD: Makefile,v 1.33 2019/08/03 15:22:21 deraadt Exp $ MAN= cdboot.8 @@ -30,8 +30,8 @@ SRCS+= bootarg.c cmd.c vars.c SRCS+= alloc.c ctime.c exit.c getchar.c memcmp.c memcpy.c memmove.c memset.c printf.c \ putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c strncpy.c \ strtol.c strtoll.c -SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ - lseek.c open.c read.c readdir.c stat.c +SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \ + fstat.c lseek.c open.c read.c readdir.c stat.c SRCS+= elf32.c elf64.c loadfile.c SRCS+= cd9660.c ufs.c SRCS+= aes_xts.c bcrypt_pbkdf.c blowfish.c explicit_bzero.c hmac_sha1.c \ diff --git a/sys/arch/i386/stand/cdboot/conf.c b/sys/arch/i386/stand/cdboot/conf.c index 85bc425a4a8..3d797291a4c 100644 --- a/sys/arch/i386/stand/cdboot/conf.c +++ b/sys/arch/i386/stand/cdboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.36 2019/04/10 04:19:32 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.37 2019/08/03 15:22:21 deraadt Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -64,7 +64,7 @@ int nibprobes = nitems(probe_list); struct fs_ops file_system[] = { { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir, ufs_fchmod }, { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek, cd9660_stat, cd9660_readdir }, #ifdef notdef diff --git a/sys/arch/i386/stand/pxeboot/Makefile b/sys/arch/i386/stand/pxeboot/Makefile index 5c678a92da7..926e2b2cf2c 100644 --- a/sys/arch/i386/stand/pxeboot/Makefile +++ b/sys/arch/i386/stand/pxeboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.29 2019/04/20 22:59:03 deraadt Exp $ +# $OpenBSD: Makefile,v 1.30 2019/08/03 15:22:21 deraadt Exp $ MAN= pxeboot.8 @@ -31,8 +31,8 @@ SRCS+= boot.c cmd.c vars.c bootarg.c SRCS+= alloc.c ctime.c exit.c getchar.c globals.c memcmp.c memmove.c memcpy.c memset.c \ printf.c putchar.c snprintf.c strcmp.c strerror.c strlen.c strncmp.c \ strncpy.c strtol.c strtoll.c -SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fstat.c \ - lseek.c read.c readdir.c stat.c +SRCS+= close.c closeall.c cons.c cread.c dev.c disklabel.c dkcksum.c fchmod.c \ + fstat.c lseek.c read.c readdir.c stat.c SRCS+= elf32.c elf64.c loadfile.c SRCS+= nfs.c ufs.c tftp.c SRCS+= bootp.c ether.c net.c netif.c rpc.c diff --git a/sys/arch/i386/stand/pxeboot/conf.c b/sys/arch/i386/stand/pxeboot/conf.c index 1a2b06afc6d..420f499f332 100644 --- a/sys/arch/i386/stand/pxeboot/conf.c +++ b/sys/arch/i386/stand/pxeboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.41 2019/04/10 04:19:32 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.42 2019/08/03 15:22:21 deraadt Exp $ */ /* * Copyright (c) 2004 Tom Cosgrove @@ -77,7 +77,7 @@ int nfsname = nitems(fs_name); struct fs_ops file_system[] = { { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir, ufs_fchmod }, { tftp_open, tftp_close, tftp_read, tftp_write, tftp_seek, tftp_stat, tftp_readdir }, { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, diff --git a/sys/arch/landisk/stand/boot/conf.c b/sys/arch/landisk/stand/boot/conf.c index 9d359e6cd60..ffb018078ec 100644 --- a/sys/arch/landisk/stand/boot/conf.c +++ b/sys/arch/landisk/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.12 2019/04/10 04:19:32 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.13 2019/08/03 15:22:21 deraadt Exp $ */ /* * Copyright (c) 2006 Michael Shalayeff @@ -34,7 +34,7 @@ int debug = 1; struct fs_ops file_system[] = { { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir, ufs_fchmod }, #ifdef notdef { fat_open, fat_close, fat_read, fat_write, fat_seek, fat_stat, fat_readdir }, diff --git a/sys/arch/landisk/stand/xxboot/boot1.c b/sys/arch/landisk/stand/xxboot/boot1.c index 0042680f2f0..5fd3dbf6374 100644 --- a/sys/arch/landisk/stand/xxboot/boot1.c +++ b/sys/arch/landisk/stand/xxboot/boot1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot1.c,v 1.7 2011/04/10 12:21:07 miod Exp $ */ +/* $OpenBSD: boot1.c,v 1.8 2019/08/03 15:22:21 deraadt Exp $ */ /* $NetBSD: boot1.c,v 1.1 2006/09/01 21:26:19 uwe Exp $ */ /*- @@ -53,7 +53,7 @@ extern struct disklabel ptn_disklabel; struct fs_ops file_system[] = { { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir }, + ufs_stat, ufs_readdir, ufs_fchmod }, }; int nfsys = nitems(file_system); diff --git a/sys/arch/loongson/stand/boot/conf.c b/sys/arch/loongson/stand/boot/conf.c index 95aa51990ed..15a37f1df11 100644 --- a/sys/arch/loongson/stand/boot/conf.c +++ b/sys/arch/loongson/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.10 2019/04/10 04:19:32 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.11 2019/08/03 15:22:21 deraadt Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -64,7 +64,7 @@ struct fs_ops file_system[] = { rdfs_seek, rdfs_stat, rdfs_readdir }, /* ufs filesystem */ { ufs_open, ufs_close, ufs_read, ufs_write, - ufs_seek, ufs_stat, ufs_readdir }, + ufs_seek, ufs_stat, ufs_readdir, ufs_fchmod }, /* cd9660 filesystem - in case a cd image is dd'ed on non USB media */ { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek, cd9660_stat, cd9660_readdir } diff --git a/sys/arch/loongson/stand/libsa/Makefile b/sys/arch/loongson/stand/libsa/Makefile index b4820f3d8cf..7a23329b899 100644 --- a/sys/arch/loongson/stand/libsa/Makefile +++ b/sys/arch/loongson/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.9 2019/04/20 22:59:03 deraadt Exp $ +# $OpenBSD: Makefile,v 1.10 2019/08/03 15:22:21 deraadt Exp $ .include "${.CURDIR}/../Makefile.inc" @@ -21,8 +21,8 @@ SRCS= alloc.c cons.c ctime.c exit.c getchar.c getfile.c getln.c globals.c \ snprintf.c strchr.c strcmp.c strerror.c strncmp.c strncpy.c strtol.c # io routines -SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fstat.c ioctl.c \ - lseek.c open.c read.c readdir.c stat.c write.c +SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fchmod.c fstat.c \ + ioctl.c lseek.c open.c read.c readdir.c stat.c write.c #SRCS+= nullfs.c #SRCS+= cread.c diff --git a/sys/arch/macppc/stand/boot.mac/Makefile b/sys/arch/macppc/stand/boot.mac/Makefile index d48bc32e675..4871944fc5d 100644 --- a/sys/arch/macppc/stand/boot.mac/Makefile +++ b/sys/arch/macppc/stand/boot.mac/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.15 2019/04/20 22:59:03 deraadt Exp $ +# $OpenBSD: Makefile,v 1.16 2019/08/03 15:22:21 deraadt Exp $ # $NetBSD: Makefile,v 1.1 1996/09/30 16:35:05 ws Exp $ S= ${.CURDIR}/../../../.. @@ -10,7 +10,7 @@ NOMAN= PROG= boot.mac CFLAGS+= -D_STANDALONE SRCS= Locore.c main.c ofdev.c net.c netif_of.c netudp.c -SRCS+= alloc.c cache.c hfs.c +SRCS+= alloc.c cache.c hfs.c fchmod.c SRCS+= boot.c conf.c cmd.c vars.c ctime.c strtol.c INSTALL_STRIP= diff --git a/sys/arch/macppc/stand/ofwboot/Makefile b/sys/arch/macppc/stand/ofwboot/Makefile index 8887ed64b0a..ec2468b05cd 100644 --- a/sys/arch/macppc/stand/ofwboot/Makefile +++ b/sys/arch/macppc/stand/ofwboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.16 2019/04/20 22:59:04 deraadt Exp $ +# $OpenBSD: Makefile,v 1.17 2019/08/03 15:22:21 deraadt Exp $ # $NetBSD: Makefile,v 1.2 1997/04/17 07:46:24 thorpej Exp $ S= ${.CURDIR}/../../../.. @@ -7,7 +7,7 @@ R=../ PROG= ofwboot CFLAGS+= -D_STANDALONE SRCS= Locore.c main.c ofdev.c net.c netif_of.c netudp.c -SRCS+= alloc.c cache.c hfs.c +SRCS+= alloc.c cache.c fchmod.c hfs.c SRCS+= boot.c conf.c cmd.c vars.c ctime.c strtol.c .PATH: ${S}/arch/macppc/stand SRCS+= ofwmagic.S diff --git a/sys/arch/sgi/stand/libsa/Makefile b/sys/arch/sgi/stand/libsa/Makefile index 30f52c4f1ce..7e07baeab99 100644 --- a/sys/arch/sgi/stand/libsa/Makefile +++ b/sys/arch/sgi/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.11 2019/04/20 22:59:04 deraadt Exp $ +# $OpenBSD: Makefile,v 1.12 2019/08/03 15:22:21 deraadt Exp $ LIB= sa @@ -21,8 +21,8 @@ SRCS= alloc.c exit.c getfile.c getln.c globals.c \ memcmp.c memcpy.c memmove.c memset.c printf.c snprintf.c strerror.c strncpy.c # io routines -SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fstat.c ioctl.c lseek.c \ - open.c read.c stat.c write.c cread.c +SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fchmod.c \ + fstat.c ioctl.c lseek.c open.c read.c stat.c write.c cread.c # boot filesystems SRCS+= ufs.c nfs.c cd9660.c diff --git a/sys/lib/libsa/Makefile b/sys/lib/libsa/Makefile index a4b9fdcf26b..8cac7712bbb 100644 --- a/sys/lib/libsa/Makefile +++ b/sys/lib/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.29 2019/04/20 22:59:04 deraadt Exp $ +# $OpenBSD: Makefile,v 1.30 2019/08/03 15:22:17 deraadt Exp $ # $NetBSD: Makefile,v 1.13 1996/10/02 16:19:51 ws Exp $ LIB= sa @@ -34,7 +34,8 @@ SRCS+= divdi3.c qdivrem.c # io routines SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c cons.c ioctl.c \ - lseek.c open.c nullfs.c read.c stat.c fstat.c write.c readdir.c + lseek.c open.c nullfs.c read.c stat.c fchmod.c fstat.c \ + write.c readdir.c # boot filesystems SRCS+= ufs.c cd9660.c diff --git a/sys/lib/libsa/fchmod.c b/sys/lib/libsa/fchmod.c new file mode 100644 index 00000000000..7d9bc9cac36 --- /dev/null +++ b/sys/lib/libsa/fchmod.c @@ -0,0 +1,59 @@ +/* $OpenBSD: fchmod.c,v 1.1 2019/08/03 15:22:17 deraadt Exp $ */ +/* $NetBSD: stat.c,v 1.3 1994/10/26 05:45:07 cgd Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stat.c 8.1 (Berkeley) 6/11/93 + */ + +#include "stand.h" + +int +fchmod(int fd, mode_t m) +{ + struct open_file *f = &files[fd]; + + if (f->f_ops->fchmod == NULL) { + errno = EOPNOTSUPP; + return (-1); + } + if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + errno = EBADF; + return (-1); + } + + /* operation not defined on raw devices */ + if (f->f_flags & F_RAW) { + errno = EOPNOTSUPP; + return (-1); + } + + errno = (f->f_ops->fchmod)(f, m); + return (0); +} diff --git a/sys/lib/libsa/stand.h b/sys/lib/libsa/stand.h index 5e78f153770..d4b56fd1331 100644 --- a/sys/lib/libsa/stand.h +++ b/sys/lib/libsa/stand.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stand.h,v 1.66 2019/04/20 22:59:04 deraadt Exp $ */ +/* $OpenBSD: stand.h,v 1.67 2019/08/03 15:22:17 deraadt Exp $ */ /* $NetBSD: stand.h,v 1.18 1996/11/30 04:35:51 gwr Exp $ */ /*- @@ -67,6 +67,7 @@ struct fs_ops { off_t (*seek)(struct open_file *f, off_t offset, int where); int (*stat)(struct open_file *f, struct stat *sb); int (*readdir)(struct open_file *f, char *); + int (*fchmod)(struct open_file *f, mode_t); }; extern struct fs_ops file_system[]; diff --git a/sys/lib/libsa/ufs.c b/sys/lib/libsa/ufs.c index e768beaef24..9ba26a49048 100644 --- a/sys/lib/libsa/ufs.c +++ b/sys/lib/libsa/ufs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs.c,v 1.26 2016/11/25 17:00:33 reyk Exp $ */ +/* $OpenBSD: ufs.c,v 1.27 2019/08/03 15:22:17 deraadt Exp $ */ /* $NetBSD: ufs.c,v 1.16 1996/09/30 16:01:22 ws Exp $ */ /*- @@ -81,6 +81,7 @@ struct file { off_t f_seekp; /* seek pointer */ struct fs *f_fs; /* pointer to super-block */ struct ufs1_dinode f_di; /* copy of on-disk inode */ + ufsino_t f_ino; /* our inode number */ int f_nindir[NIADDR]; /* number of blocks mapped by indirect block at level i */ @@ -95,6 +96,7 @@ struct file { }; static int read_inode(ufsino_t, struct open_file *); +static int chmod_inode(ufsino_t, struct open_file *, mode_t); static int block_map(struct open_file *, daddr32_t, daddr32_t *); static int buf_read_file(struct open_file *, char **, size_t *); static int search_directory(char *, struct open_file *, ufsino_t *); @@ -154,6 +156,50 @@ out: } /* + * Read a new inode into a file structure. + */ +static int +chmod_inode(ufsino_t inumber, struct open_file *f, mode_t mode) +{ + struct file *fp = (struct file *)f->f_fsdata; + struct fs *fs = fp->f_fs; + char *buf; + size_t rsize; + int rc; + + /* + * Read inode and save it. + */ + buf = alloc(fs->fs_bsize); + twiddle(); + rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ, + fsbtodb(fs, (daddr32_t)ino_to_fsba(fs, inumber)), fs->fs_bsize, + buf, &rsize); + if (rc) + goto out; + if (rsize != (size_t)fs->fs_bsize) { + rc = EIO; + goto out; + } + + { + struct ufs1_dinode *dp; + + dp = &((struct ufs1_dinode *)buf)[ino_to_fsbo(fs, inumber)]; + dp->di_mode = mode; + } + + twiddle(); + rc = (f->f_dev->dv_strategy)(f->f_devdata, F_WRITE, + fsbtodb(fs, (daddr32_t)ino_to_fsba(fs, inumber)), fs->fs_bsize, + buf, NULL); + +out: + free(buf, fs->fs_bsize); + return (rc); +} + +/* * Given an offset in a file, find the disk block number that * contains that block. */ @@ -522,6 +568,7 @@ ufs_open(char *path, struct open_file *f) /* * Found terminal component. */ + fp->f_ino = inumber; rc = 0; out: if (buf) @@ -639,6 +686,14 @@ ufs_stat(struct open_file *f, struct stat *sb) return (0); } +int +ufs_fchmod(struct open_file *f, mode_t mode) +{ + struct file *fp = (struct file *)f->f_fsdata; + + return chmod_inode(fp->f_ino, f, mode); +} + #ifndef NO_READDIR int ufs_readdir(struct open_file *f, char *name) diff --git a/sys/lib/libsa/ufs.h b/sys/lib/libsa/ufs.h index 3f68af48d24..42122d1448c 100644 --- a/sys/lib/libsa/ufs.h +++ b/sys/lib/libsa/ufs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs.h,v 1.6 2003/06/02 23:28:10 millert Exp $ */ +/* $OpenBSD: ufs.h,v 1.7 2019/08/03 15:22:17 deraadt Exp $ */ /* $NetBSD: ufs.h,v 1.5 1995/10/20 01:35:25 cgd Exp $ */ /*- @@ -41,4 +41,5 @@ int ufs_write(struct open_file *f, void *buf, off_t ufs_seek(struct open_file *f, off_t offset, int where); int ufs_stat(struct open_file *f, struct stat *sb); int ufs_readdir(struct open_file *f, char *name); +int ufs_fchmod(struct open_file *f, mode_t mode); diff --git a/sys/lib/libsa/ufs2.c b/sys/lib/libsa/ufs2.c index b4b68c8eb0c..f36d2d155d2 100644 --- a/sys/lib/libsa/ufs2.c +++ b/sys/lib/libsa/ufs2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs2.c,v 1.7 2016/11/27 13:57:32 reyk Exp $ */ +/* $OpenBSD: ufs2.c,v 1.8 2019/08/03 15:22:17 deraadt Exp $ */ /*- * Copyright (c) 1993 @@ -80,6 +80,7 @@ struct file { off_t f_seekp; /* seek pointer */ struct fs *f_fs; /* pointer to super-block */ struct ufs2_dinode f_di; /* copy of on-disk inode */ + ufsino_t f_ino; /* our inode number */ int f_nindir[NIADDR]; /* number of blocks mapped by indirect block at level i */ @@ -94,6 +95,7 @@ struct file { }; static int read_inode(ufsino_t, struct open_file *); +static int chmod_inode(ufsino_t, struct open_file *, mode_t); static int block_map(struct open_file *, daddr_t, daddr_t *); static int buf_read_file(struct open_file *, char **, size_t *); static int search_directory(char *, struct open_file *, ufsino_t *); @@ -152,6 +154,48 @@ out: } /* + * Read a new inode into a file structure. + */ +static int +chmod_inode(ufsino_t inumber, struct open_file *f, mode_t mode) +{ + struct file *fp = (struct file *)f->f_fsdata; + struct fs *fs = fp->f_fs; + char *buf; + size_t rsize; + int rc; + + /* + * Read inode and save it. + */ + buf = alloc(fs->fs_bsize); + twiddle(); + rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ, + fsbtodb(fs, ino_to_fsba(fs, inumber)), fs->fs_bsize, buf, &rsize); + if (rc) + goto out; + if (rsize != (size_t)fs->fs_bsize) { + rc = EIO; + goto out; + } + + { + struct ufs2_dinode *dp; + + dp = &((struct ufs2_dinode *)buf)[ino_to_fsbo(fs, inumber)]; + dp->di_mode = mode; + } + + twiddle(); + rc = (f->f_dev->dv_strategy)(f->f_devdata, F_WRITE, + fsbtodb(fs, ino_to_fsba(fs, inumber)), fs->fs_bsize, buf, NULL); + +out: + free(buf, fs->fs_bsize); + return (rc); +} + +/* * Given an offset in a file, find the disk block number that * contains that block. */ @@ -520,6 +564,7 @@ ufs2_open(char *path, struct open_file *f) /* * Found terminal component. */ + fp->f_ino = inumber; rc = 0; out: if (buf) @@ -637,6 +682,14 @@ ufs2_stat(struct open_file *f, struct stat *sb) return (0); } +int +ufs2_fchmod(struct open_file *f, mode_t mode) +{ + struct file *fp = (struct file *)f->f_fsdata; + + return chmod_inode(fp->f_ino, f, mode); +} + #ifndef NO_READDIR int ufs2_readdir(struct open_file *f, char *name) diff --git a/sys/stand/boot/boot.c b/sys/stand/boot/boot.c index 31a2ddf8a0a..ccf23960338 100644 --- a/sys/stand/boot/boot.c +++ b/sys/stand/boot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.48 2019/04/10 19:41:03 florian Exp $ */ +/* $OpenBSD: boot.c,v 1.49 2019/08/03 15:22:19 deraadt Exp $ */ /* * Copyright (c) 2003 Dale Rahn @@ -59,7 +59,7 @@ char rnddata[BOOTRANDOM_MAX]; void boot(dev_t bootdev) { - int fd; + int fd, isupgrade = 0; int try = 0, st; uint64_t marks[MARK_MAX]; @@ -79,6 +79,7 @@ boot(dev_t bootdev) if (upgrade()) { strlcpy(cmd.image, "/bsd.upgrade", sizeof(cmd.image)); printf("upgrade detected: switching to %s\n", cmd.image); + isupgrade = 1; } st = read_conf(); @@ -118,6 +119,18 @@ boot(dev_t bootdev) printf("booting %s: ", cmd.path); marks[MARK_START] = (u_long)cmd.addr; if ((fd = loadfile(cmd.path, marks, LOAD_ALL)) != -1) { + + /* Prevent re-upgrade: chmod a-x bsd.upgrade */ + if (isupgrade) { + struct stat st; + + if (fstat(fd, &st) == 0) { + st.st_mode &= ~(S_IXUSR|S_IXGRP|S_IXOTH); + if (fchmod(fd, st.st_mode) == -1) + printf("fchmod a-x %s: failed\n", + cmd.path); + } + } close(fd); break; } diff --git a/sys/stand/boot/cmd.c b/sys/stand/boot/cmd.c index 9923380ee5e..a03b7d662aa 100644 --- a/sys/stand/boot/cmd.c +++ b/sys/stand/boot/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.64 2019/04/08 13:55:46 florian Exp $ */ +/* $OpenBSD: cmd.c,v 1.65 2019/08/03 15:22:19 deraadt Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -530,5 +530,9 @@ upgrade(void) if (stat(qualify(("/bsd.upgrade")), &sb) < 0) return 0; + if ((sb.st_mode & S_IXUSR) == 0) { + printf("/bsd.upgrade is not u+x\n"); + return 0; + } return 1; } |