diff options
Diffstat (limited to 'usr/src')
79 files changed, 1349 insertions, 928 deletions
diff --git a/usr/src/cmd/auditrecord/audit_record_attr.txt b/usr/src/cmd/auditrecord/audit_record_attr.txt index 24dd6b5791..3db147736a 100644 --- a/usr/src/cmd/auditrecord/audit_record_attr.txt +++ b/usr/src/cmd/auditrecord/audit_record_attr.txt @@ -1300,6 +1300,14 @@ label=AUE_OPENAT_WTC see=openat(2) format=path:[path_attr]:[attr] +label=AUE_OPEN_S + format=path:[path_attr]:[attr] + see=open(2) - search + +label=AUE_OPEN_E + format=path:[path_attr]:[attr] + see=open(2) - exec + label=AUE_OSETPGRP skip=Not used. diff --git a/usr/src/cmd/ptools/pfiles/pfiles.c b/usr/src/cmd/ptools/pfiles/pfiles.c index 5bd1373a1d..b41ea95f85 100644 --- a/usr/src/cmd/ptools/pfiles/pfiles.c +++ b/usr/src/cmd/ptools/pfiles/pfiles.c @@ -408,15 +408,9 @@ dofcntl(struct ps_prochandle *Pr, int fd, int mandatory, int isdoor) } } -#ifdef O_PRIV -#define ALL_O_FLAGS O_ACCMODE | O_NDELAY | O_NONBLOCK | O_APPEND | \ - O_PRIV | O_SYNC | O_DSYNC | O_RSYNC | O_XATTR | \ - O_CREAT | O_TRUNC | O_EXCL | O_NOCTTY | O_LARGEFILE -#else #define ALL_O_FLAGS O_ACCMODE | O_NDELAY | O_NONBLOCK | O_APPEND | \ O_SYNC | O_DSYNC | O_RSYNC | O_XATTR | \ O_CREAT | O_TRUNC | O_EXCL | O_NOCTTY | O_LARGEFILE -#endif static void show_fileflags(int flags) @@ -434,6 +428,12 @@ show_fileflags(int flags) case O_RDWR: (void) strcpy(str, "O_RDWR"); break; + case O_SEARCH: + (void) strcpy(str, "O_SEARCH"); + break; + case O_EXEC: + (void) strcpy(str, "O_EXEC"); + break; default: (void) sprintf(str, "0x%x", flags & O_ACCMODE); break; @@ -445,10 +445,6 @@ show_fileflags(int flags) (void) strcat(str, "|O_NONBLOCK"); if (flags & O_APPEND) (void) strcat(str, "|O_APPEND"); -#ifdef O_PRIV - if (flags & O_PRIV) - (void) strcat(str, "|O_PRIV"); -#endif if (flags & O_SYNC) (void) strcat(str, "|O_SYNC"); if (flags & O_DSYNC) diff --git a/usr/src/cmd/truss/codes.c b/usr/src/cmd/truss/codes.c index 55dea4c7c7..c7d036a4a4 100644 --- a/usr/src/cmd/truss/codes.c +++ b/usr/src/cmd/truss/codes.c @@ -18,8 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -1894,9 +1895,12 @@ openarg(private_t *pri, int arg) { char *str = pri->code_buf; - switch (arg & ~ALL_O_FLAGS) { + if ((arg & ~(O_ACCMODE | ALL_O_FLAGS)) != 0) + return (NULL); + + switch (arg & O_ACCMODE) { default: - return ((char *)NULL); + return (NULL); case O_RDONLY: (void) strcpy(str, "O_RDONLY"); break; @@ -1906,6 +1910,12 @@ openarg(private_t *pri, int arg) case O_RDWR: (void) strcpy(str, "O_RDWR"); break; + case O_SEARCH: + (void) strcpy(str, "O_SEARCH"); + break; + case O_EXEC: + (void) strcpy(str, "O_EXEC"); + break; } if (arg & O_NDELAY) diff --git a/usr/src/cmd/truss/listopts.c b/usr/src/cmd/truss/listopts.c index 0d32d15561..17d9a50ecc 100644 --- a/usr/src/cmd/truss/listopts.c +++ b/usr/src/cmd/truss/listopts.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -226,26 +225,42 @@ syslist(char *str, /* string of syscall names */ sysx = SYS_renameat; goto def; - case SYS_unlink: /* set both */ - sysx = SYS_unlinkat; + case SYS_link: /* set both */ + sysx = SYS_linkat; goto def; + case SYS_unlink: /* set both */ case SYS_rmdir: /* set both */ sysx = SYS_unlinkat; goto def; - case SYS_chown: /* set both */ - sysx = SYS_fchownat; + case SYS_symlink: /* set both */ + sysx = SYS_symlinkat; goto def; - case SYS_lchown: /* set both */ - sysx = SYS_fchownat; + case SYS_readlink: /* set both */ + sysx = SYS_readlinkat; goto def; + case SYS_chmod: /* set both */ + case SYS_fchmod: /* set both */ + sysx = SYS_fchmodat; + goto def; + + case SYS_chown: /* set both */ + case SYS_lchown: /* set both */ case SYS_fchown: /* set both */ sysx = SYS_fchownat; goto def; + case SYS_mkdir: /* set both */ + sysx = SYS_mkdirat; + goto def; + + case SYS_mknod: /* set both */ + sysx = SYS_mknodat; + goto def; + case SYS_access: /* set both */ sysx = SYS_faccessat; goto def; diff --git a/usr/src/cmd/truss/print.c b/usr/src/cmd/truss/print.c index 1a92777c28..d676afa56e 100644 --- a/usr/src/cmd/truss/print.c +++ b/usr/src/cmd/truss/print.c @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -2619,15 +2620,45 @@ prt_fxf(private_t *pri, int raw, long val) } /* - * Print utimensat() flag + * Print faccessat() flag + */ +void +prt_fat(private_t *pri, int raw, long val) +{ + if (val == 0) + outstring(pri, "0"); + else if (!raw && val == AT_EACCESS) + outstring(pri, "AT_EACCESS"); + else + prt_hex(pri, 0, val); +} + +/* + * Print unlinkat() flag + */ +void +prt_uat(private_t *pri, int raw, long val) +{ + if (val == 0) + outstring(pri, "0"); + else if (!raw && val == AT_REMOVEDIR) + outstring(pri, "AT_REMOVEDIR"); + else + prt_hex(pri, 0, val); +} + +/* + * Print AT_SYMLINK_NOFOLLOW / AT_SYMLINK_FOLLOW flag */ void -prt_utf(private_t *pri, int raw, long val) +prt_snf(private_t *pri, int raw, long val) { if (val == 0) outstring(pri, "0"); else if (!raw && val == AT_SYMLINK_NOFOLLOW) outstring(pri, "AT_SYMLINK_NOFOLLOW"); + else if (!raw && val == AT_SYMLINK_FOLLOW) + outstring(pri, "AT_SYMLINK_FOLLOW"); else prt_hex(pri, 0, val); } @@ -2648,14 +2679,14 @@ void (* const Print[])() = { prt_uts, /* UTS -- print utssys code */ prt_opn, /* OPN -- print open code */ prt_sig, /* SIG -- print signal name plus flags */ - prt_nov, /* Was ACT, now available for reuse */ + prt_uat, /* UAT -- print unlinkat() flag */ prt_msc, /* MSC -- print msgsys command */ prt_msf, /* MSF -- print msgsys flags */ prt_smc, /* SMC -- print semsys command */ prt_sef, /* SEF -- print semsys flags */ prt_shc, /* SHC -- print shmsys command */ prt_shf, /* SHF -- print shmsys flags */ - prt_nov, /* Was PLK, now available for reuse */ + prt_fat, /* FAT -- print faccessat( flag */ prt_sfs, /* SFS -- print sysfs code */ prt_rst, /* RST -- print string returned by syscall */ prt_smf, /* SMF -- print streams message flags */ @@ -2733,7 +2764,7 @@ void (* const Print[])() = { prt_spf, /* SPF -- print rctlsys_projset() flags */ prt_un1, /* UN1 -- as prt_uns except for -1 */ prt_mob, /* MOB -- print mmapobj() flags */ - prt_utf, /* UTF -- print utimensat() flag */ + prt_snf, /* SNF -- print AT_SYMLINK_[NO]FOLLOW flag */ prt_skc, /* SKC -- print sockconfig() subcode */ prt_dec, /* HID -- hidden argument, make this the last one */ }; diff --git a/usr/src/cmd/truss/print.h b/usr/src/cmd/truss/print.h index 7a190f9cab..98c2223052 100644 --- a/usr/src/cmd/truss/print.h +++ b/usr/src/cmd/truss/print.h @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -48,14 +49,14 @@ extern "C" { #define UTS 9 /* print utssys code */ #define OPN 10 /* print open code */ #define SIG 11 /* print signal name plus flags */ -/* Number 12 now available for reuse */ +#define UAT 12 /* print unlinkat() flag */ #define MSC 13 /* print msgsys command */ #define MSF 14 /* print msgsys flags */ #define SMC 15 /* print semsys command */ #define SEF 16 /* print semsys flags */ #define SHC 17 /* print shmsys command */ #define SHF 18 /* print shmsys flags */ -/* Number 19 now available for reuse */ +#define FAT 19 /* print faccessat() flag */ #define SFS 20 /* print sysfs code */ #define RST 21 /* print string returned by sys call */ #define SMF 22 /* print streams message flags */ @@ -133,7 +134,7 @@ extern "C" { #define SPF 94 /* print rctlsys_projset flags */ #define UN1 95 /* unsigned except for -1 */ #define MOB 96 /* print mmapobj() flags */ -#define UTF 97 /* print utimensat() flag */ +#define SNF 97 /* print AT_SYMLINK_[NO]FOLLOW flag */ #define SKC 98 /* print sockconfig subcode */ #define HID 99 /* hidden argument, don't print */ /* make sure HID is always the last member */ diff --git a/usr/src/cmd/truss/systable.c b/usr/src/cmd/truss/systable.c index b8bdbe6af5..66ae2525f4 100644 --- a/usr/src/cmd/truss/systable.c +++ b/usr/src/cmd/truss/systable.c @@ -223,11 +223,11 @@ const struct systable systable[] = { {"write", 3, DEC, NOV, DEC, IOB, UNS}, /* 4 */ {"open", 3, DEC, NOV, STG, OPN, OCT}, /* 5 */ {"close", 1, DEC, NOV, DEC}, /* 6 */ -{ NULL, 8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX}, +{"linkat", 5, DEC, NOV, ATC, STG, ATC, STG, SNF}, /* 7 */ { NULL, 8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX}, {"link", 2, DEC, NOV, STG, STG}, /* 9 */ {"unlink", 1, DEC, NOV, STG}, /* 10 */ -{ NULL, 8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX}, +{"symlinkat", 3, DEC, NOV, STG, ATC, STG}, /* 11 */ {"chdir", 1, DEC, NOV, STG}, /* 12 */ {"time", 0, DEC, NOV}, /* 13 */ {"mknod", 3, DEC, NOV, STG, OCT, HEX}, /* 14 */ @@ -238,7 +238,7 @@ const struct systable systable[] = { {"lseek", 3, DEC, NOV, DEC, DEX, WHN}, /* 19 */ {"getpid", 0, DEC, DEC}, /* 20 */ {"mount", 8, DEC, NOV, STG, STG, MTF, MFT, HEX, DEC, HEX, DEC}, /* 21 */ -{ NULL, 8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX}, +{"readlinkat", 4, DEC, NOV, ATC, STG, RLK, UNS}, /* 22 */ {"setuid", 1, DEC, NOV, UNS}, /* 23 */ {"getuid", 0, UNS, UNS}, /* 24 */ {"stime", 1, DEC, NOV, DEC}, /* 25 */ @@ -261,10 +261,10 @@ const struct systable systable[] = { {"pipe", 0, DEC, DEC}, /* 42 */ {"times", 1, DEC, NOV, HEX}, /* 43 */ {"profil", 4, DEC, NOV, HEX, UNS, HEX, OCT}, /* 44 */ -{"faccessat", 4, DEC, NOV, ATC, STG, ACC, DEC}, /* 45 */ +{"faccessat", 4, DEC, NOV, ATC, STG, ACC, FAT}, /* 45 */ {"setgid", 1, DEC, NOV, UNS}, /* 46 */ {"getgid", 0, UNS, UNS}, /* 47 */ -{ NULL, 8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX}, +{"mknodat", 4, DEC, NOV, ATC, STG, OCT, HEX}, /* 48 */ {"msgsys", 6, DEC, NOV, DEC, DEC, DEC, DEC, DEC, DEC}, /* 49 */ {"sysi86", 4, HEX, NOV, S86, HEX, HEX, HEX, DEC, DEC}, /* 50 */ {"acct", 1, DEC, NOV, STG}, /* 51 */ @@ -272,7 +272,7 @@ const struct systable systable[] = { {"semsys", 5, DEC, NOV, DEC, HEX, HEX, HEX, HEX}, /* 53 */ {"ioctl", 3, DEC, NOV, DEC, IOC, IOA}, /* 54 */ {"uadmin", 3, DEC, NOV, DEC, DEC, DEC}, /* 55 */ -{"fchownat", 5, DEC, NOV, ATC, STG, DEC, DEC, UTF}, /* 56 */ +{"fchownat", 5, DEC, NOV, ATC, STG, DEC, DEC, SNF}, /* 56 */ {"utssys", 4, DEC, NOV, HEX, DEC, UTS, HEX}, /* 57 */ {"fdsync", 2, DEC, NOV, DEC, FFG}, /* 58 */ {"execve", 3, DEC, NOV, STG, HEX, HEX}, /* 59 */ @@ -281,9 +281,9 @@ const struct systable systable[] = { {"fcntl", 3, DEC, NOV, DEC, FCN, HEX}, /* 62 */ {"ulimit", 2, DEX, NOV, ULM, DEC}, /* 63 */ {"renameat", 4, DEC, NOV, ATC, STG, ATC, STG}, /* 64 */ -{"unlinkat", 3, DEC, NOV, ATC, STG, DEC}, /* 65 */ -{"fstatat", 4, DEC, NOV, ATC, STG, HEX, UTF}, /* 66 */ -{"fstatat64", 4, DEC, NOV, ATC, STG, HEX, UTF}, /* 67 */ +{"unlinkat", 3, DEC, NOV, ATC, STG, UAT}, /* 65 */ +{"fstatat", 4, DEC, NOV, ATC, STG, HEX, SNF}, /* 66 */ +{"fstatat64", 4, DEC, NOV, ATC, STG, HEX, SNF}, /* 67 */ {"openat", 4, DEC, NOV, ATC, STG, OPN, OCT}, /* 68 */ {"openat64", 4, DEC, NOV, ATC, STG, OPN, OCT}, /* 69 */ {"tasksys", 5, DEC, NOV, DEC, DEC, DEC, HEX, DEC}, /* 70 */ @@ -317,8 +317,8 @@ const struct systable systable[] = { {"sigaction", 3, DEC, NOV, SIG, HEX, HEX}, /* 98 */ {"sigpendsys", 2, DEC, NOV, DEC, HEX}, /* 99 */ {"context", 2, DEC, NOV, DEC, HEX}, /* 100 */ -{ NULL, 8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX}, -{ NULL, 8, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX, HEX}, +{"fchmodat", 4, DEC, NOV, ATC, STG, OCT, SNF}, /* 101 */ +{"mkdirat", 3, DEC, NOV, ATC, STG, OCT}, /* 102 */ {"statvfs", 2, DEC, NOV, STG, HEX}, /* 103 */ {"fstatvfs", 2, DEC, NOV, DEC, HEX}, /* 104 */ {"getloadavg", 2, DEC, NOV, HEX, DEC}, /* 105 */ @@ -484,34 +484,72 @@ const struct systable systable[] = { */ const struct systable faccessattable[] = { -{"faccessat", 4, DEC, NOV, ATC, STG, ACC, DEC}, /* 0 */ +{"faccessat", 4, DEC, NOV, ATC, STG, ACC, FAT}, /* 0 */ {"access", 3, DEC, NOV, HID, STG, ACC}, /* 1 */ }; #define NACCESSCODE (sizeof (faccessattable) / sizeof (struct systable)) +const struct systable fchmodattable[] = { +{"fchmodat", 4, DEC, NOV, ATC, STG, OCT, SNF}, /* 0 */ +{"chmod", 3, DEC, NOV, HID, STG, OCT}, /* 1 */ +{"fchmodat", 4, DEC, NOV, ATC, STG, OCT, SNF}, /* 2 */ +{"fchmod", 3, DEC, NOV, DEC, HID, OCT}, /* 3 */ +}; +#define NCHMODCODE (sizeof (fchmodattable) / sizeof (struct systable)) + const struct systable fchownattable[] = { -{"fchownat", 5, DEC, NOV, ATC, STG, DEC, DEC, UTF}, /* 0 */ +{"fchownat", 5, DEC, NOV, ATC, STG, DEC, DEC, SNF}, /* 0 */ {"chown", 4, DEC, NOV, HID, STG, DEC, DEC}, /* 1 */ {"lchown", 4, DEC, NOV, HID, STG, DEC, DEC}, /* 2 */ {"fchown", 4, DEC, NOV, DEC, HID, DEC, DEC}, /* 3 */ }; #define NCHOWNCODE (sizeof (fchownattable) / sizeof (struct systable)) +const struct systable mkdiratattable[] = { +{"mkdirat", 3, DEC, NOV, ATC, STG, OCT}, /* 0 */ +{"mkdir", 3, DEC, NOV, HID, STG, OCT}, /* 1 */ +}; +#define NMKDIRCODE (sizeof (mkdiratattable) / sizeof (struct systable)) + +const struct systable mknodatattable[] = { +{"mknodat", 4, DEC, NOV, ATC, STG, OCT, HEX}, /* 0 */ +{"mknod", 4, DEC, NOV, HID, STG, OCT, HEX}, /* 1 */ +}; +#define NMKMODCODE (sizeof (mknodatattable) / sizeof (struct systable)) + const struct systable renameattable[] = { {"renameat", 4, DEC, NOV, ATC, STG, ATC, STG}, /* 0 */ {"rename", 4, DEC, NOV, HID, STG, HID, STG}, /* 1 */ }; #define NRENAMECODE (sizeof (renameattable) / sizeof (struct systable)) +const struct systable linkattable[] = { +{"linkat", 5, DEC, NOV, ATC, STG, ATC, STG, SNF}, /* 0 */ +{"link", 4, DEC, NOV, HID, STG, HID, STG}, /* 1 */ +}; +#define NLINKATCODE (sizeof (linkattable) / sizeof (struct systable)) + const struct systable unlinkattable[] = { -{"unlinkat", 3, DEC, NOV, ATC, STG, DEC}, /* 0 */ +{"unlinkat", 3, DEC, NOV, ATC, STG, UAT}, /* 0 */ {"unlink", 2, DEC, NOV, HID, STG}, /* 1 */ {"rmdir", 2, DEC, NOV, HID, STG}, /* 2 */ }; #define NUNLINKCODE (sizeof (unlinkattable) / sizeof (struct systable)) +const struct systable symlinkattable[] = { +{"symlinkat", 3, DEC, NOV, STG, ATC, STG}, /* 0 */ +{"symlink", 3, DEC, NOV, STG, HID, STG}, /* 1 */ +}; +#define NSYMLINKCODE (sizeof (symlinkattable) / sizeof (struct systable)) + +const struct systable readlinkattable[] = { +{"readlinkat", 4, DEC, NOV, ATC, STG, RLK, UNS}, /* 0 */ +{"readlink", 4, DEC, NOV, HID, STG, RLK, UNS}, /* 1 */ +}; +#define NREADLINKCODE (sizeof (readlinkattable) / sizeof (struct systable)) + const struct systable fstatattable[] = { -{"fstatat", 4, DEC, NOV, ATC, STG, HEX, UTF}, /* 0 */ +{"fstatat", 4, DEC, NOV, ATC, STG, HEX, SNF}, /* 0 */ {"stat", 3, DEC, NOV, HID, STG, HEX}, /* 1 */ {"lstat", 3, DEC, NOV, HID, STG, HEX}, /* 2 */ {"fstat", 3, DEC, NOV, DEC, HID, HEX}, /* 3 */ @@ -519,7 +557,7 @@ const struct systable fstatattable[] = { #define NSTATCODE (sizeof (fstatattable) / sizeof (struct systable)) const struct systable fstatat64table[] = { -{"fstatat64", 4, DEC, NOV, ATC, STG, HEX, UTF}, /* 0 */ +{"fstatat64", 4, DEC, NOV, ATC, STG, HEX, SNF}, /* 0 */ {"stat64", 3, DEC, NOV, HID, STG, HEX}, /* 1 */ {"lstat64", 3, DEC, NOV, HID, STG, HEX}, /* 2 */ {"fstat64", 3, DEC, NOV, DEC, HID, HEX}, /* 3 */ @@ -868,7 +906,7 @@ const struct systable sidsystable[] = { const struct systable utimesystable[] = { {"futimens", 3, DEC, NOV, HID, DEC, HEX}, /* 0 */ -{"utimensat", 5, DEC, NOV, HID, ATC, STG, HEX, UTF}, /* 1 */ +{"utimensat", 5, DEC, NOV, HID, ATC, STG, HEX, SNF}, /* 1 */ }; #define NUTIMESYSCODE (sizeof (utimesystable) / sizeof (struct systable)) @@ -1051,18 +1089,42 @@ subsys(int syscall, int subcode) if ((unsigned)subcode < NACCESSCODE) stp = &faccessattable[subcode]; break; + case SYS_fchmodat: + if ((unsigned)subcode < NCHMODCODE) + stp = &fchmodattable[subcode]; + break; case SYS_fchownat: if ((unsigned)subcode < NCHOWNCODE) stp = &fchownattable[subcode]; break; + case SYS_mkdirat: + if ((unsigned)subcode < NMKDIRCODE) + stp = &mkdiratattable[subcode]; + break; + case SYS_mknodat: + if ((unsigned)subcode < NMKMODCODE) + stp = &mknodatattable[subcode]; + break; case SYS_renameat: if ((unsigned)subcode < NRENAMECODE) stp = &renameattable[subcode]; break; + case SYS_linkat: + if ((unsigned)subcode < NLINKATCODE) + stp = &linkattable[subcode]; + break; case SYS_unlinkat: if ((unsigned)subcode < NUNLINKCODE) stp = &unlinkattable[subcode]; break; + case SYS_symlinkat: + if ((unsigned)subcode < NSYMLINKCODE) + stp = &symlinkattable[subcode]; + break; + case SYS_readlinkat: + if ((unsigned)subcode < NREADLINKCODE) + stp = &readlinkattable[subcode]; + break; case SYS_fstatat: if ((unsigned)subcode < NSTATCODE) stp = &fstatattable[subcode]; @@ -1299,6 +1361,20 @@ getsubcode(private_t *pri) subcode = ((int)Lsp->pr_sysarg[0] == AT_FDCWD && Lsp->pr_sysarg[3] == 0)? 1 : 0; break; + case SYS_fchmodat: + if (nsysarg > 1 && Lsp->pr_sysarg[1] == NULL) { + subcode = 3; + break; + } + if (nsysarg > 0 && (int)Lsp->pr_sysarg[0] != AT_FDCWD) { + subcode = 0; + break; + } + if (nsysarg > 3) + subcode = (Lsp->pr_sysarg[3] == 0)? 1 : + (Lsp->pr_sysarg[3] == AT_SYMLINK_NOFOLLOW)? + 2 : 0; + break; case SYS_fchownat: if (nsysarg > 1 && Lsp->pr_sysarg[1] == NULL) { subcode = 3; @@ -1313,11 +1389,24 @@ getsubcode(private_t *pri) (Lsp->pr_sysarg[4] == AT_SYMLINK_NOFOLLOW)? 2 : 0; break; + case SYS_mkdirat: + case SYS_mknodat: + case SYS_readlinkat: + if (nsysarg > 0) + subcode = ((int)Lsp->pr_sysarg[0] == AT_FDCWD)? + 1 : 0; + break; case SYS_renameat: if (nsysarg > 2) subcode = ((int)Lsp->pr_sysarg[0] == AT_FDCWD && (int)Lsp->pr_sysarg[2] == AT_FDCWD)? 1 : 0; break; + case SYS_linkat: + if (nsysarg > 4) + subcode = ((int)Lsp->pr_sysarg[0] == AT_FDCWD && + (int)Lsp->pr_sysarg[2] == AT_FDCWD && + Lsp->pr_sysarg[4] == 0)? 1 : 0; + break; case SYS_unlinkat: if (nsysarg > 2) subcode = @@ -1325,6 +1414,11 @@ getsubcode(private_t *pri) (Lsp->pr_sysarg[2] == AT_REMOVEDIR)? 2 : (Lsp->pr_sysarg[2] == 0)? 1 : 0; break; + case SYS_symlinkat: + if (nsysarg > 1) + subcode = ((int)Lsp->pr_sysarg[1] == AT_FDCWD)? + 1 : 0; + break; case SYS_fstatat: case SYS_fstatat64: if (nsysarg > 1 && Lsp->pr_sysarg[1] == NULL) { @@ -1426,9 +1520,15 @@ maxsyscalls() { return (PRMAXSYS + 1 + NACCESSCODE - 1 + + NCHMODCODE - 1 + NCHOWNCODE - 1 + + NMKDIRCODE - 1 + + NMKMODCODE - 1 + NRENAMECODE - 1 + + NLINKATCODE - 1 + NUNLINKCODE - 1 + + NSYMLINKCODE - 1 + + NREADLINKCODE - 1 + NSTATCODE - 1 + NSTAT64CODE - 1 + NOPENATCODE - 1 @@ -1478,12 +1578,24 @@ nsubcodes(int syscall) switch (syscall) { case SYS_faccessat: return (NACCESSCODE); + case SYS_fchmodat: + return (NCHMODCODE); case SYS_fchownat: return (NCHOWNCODE); + case SYS_mkdirat: + return (NMKDIRCODE); + case SYS_mknodat: + return (NMKMODCODE); case SYS_renameat: return (NRENAMECODE); + case SYS_linkat: + return (NLINKATCODE); case SYS_unlinkat: return (NUNLINKCODE); + case SYS_symlinkat: + return (NSYMLINKCODE); + case SYS_readlinkat: + return (NREADLINKCODE); case SYS_fstatat: return (NSTATCODE); case SYS_fstatat64: diff --git a/usr/src/head/unistd.h b/usr/src/head/unistd.h index 458848701f..153773ca60 100644 --- a/usr/src/head/unistd.h +++ b/usr/src/head/unistd.h @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ @@ -300,10 +299,6 @@ extern int fattach(int, const char *); #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) extern int fchdir(int); extern int fchown(int, uid_t, gid_t); -#if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \ - defined(__EXTENSIONS__) -extern int fchownat(int, const char *, uid_t, gid_t, int); -#endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) extern int fchroot(int); @@ -464,10 +459,6 @@ extern ssize_t readlink(const char *_RESTRICT_KYWD, char *_RESTRICT_KYWD, defined(__EXTENSIONS__) extern int rename(const char *, const char *); #endif /* (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3)... */ -#if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \ - defined(__EXTENSIONS__) -extern int renameat(int, const char *, int, const char *); -#endif /* !defined(__XOPEN_OR_POSIX || defined(_ATFILE_SOURCE)... */ #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) extern int resolvepath(const char *, char *, size_t); /* per RFC 3542; This is also defined in netdb.h */ @@ -541,10 +532,6 @@ extern char *ttyname(int); extern useconds_t ualarm(useconds_t, useconds_t); #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ extern int unlink(const char *); -#if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \ - defined(__EXTENSIONS__) -extern int unlinkat(int, const char *, int); -#endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) extern int usleep(useconds_t); #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ @@ -558,10 +545,19 @@ extern ssize_t write(int, const void *, size_t); #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) extern void yield(void); #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + #if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \ defined(__EXTENSIONS__) + /* || defined(_XPG7) */ extern int faccessat(int, const char *, int, int); -#endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ +extern int fchownat(int, const char *, uid_t, gid_t, int); +extern int linkat(int, const char *, int, const char *, int); +extern ssize_t readlinkat(int, const char *_RESTRICT_KYWD, + char *_RESTRICT_KYWD, size_t); +extern int renameat(int, const char *, int, const char *); +extern int symlinkat(const char *, int, const char *); +extern int unlinkat(int, const char *, int); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ /* transitional large file interface versions */ #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ @@ -627,10 +623,6 @@ extern int fattach(); #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) extern int fchdir(); extern int fchown(); -#if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \ - defined(__EXTENSIONS__) -extern int fchownat(); -#endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) extern int fchroot(); @@ -765,10 +757,6 @@ extern ssize_t readlink(); #if (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3) && !defined(_XPG4))) || \ defined(__EXTENSIONS__) extern int rename(); -#if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \ - defined(__EXTENSIONS__) -extern int renameat(); -#endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ #endif /* (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3)... */ #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) extern int resolvepath(); @@ -842,10 +830,6 @@ extern char *ttyname(); extern useconds_t ualarm(); #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ extern int unlink(); -#if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \ - defined(__EXTENSIONS__) -extern int unlinkat(); -#endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) extern int usleep(); #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ @@ -859,10 +843,18 @@ extern ssize_t write(); #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) extern void yield(); #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ + #if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \ defined(__EXTENSIONS__) + /* || defined(_XPG7) */ extern int faccessat(); -#endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ +extern int fchownat(); +extern int linkat(); +extern ssize_t readlinkat(); +extern int renameat(); +extern int symlinkat(); +extern int unlinkat(); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ /* transitional large file interface versions */ #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ diff --git a/usr/src/lib/brand/sn1/sn1_brand/common/sn1_brand.c b/usr/src/lib/brand/sn1/sn1_brand/common/sn1_brand.c index e3941063d2..39d27749cd 100644 --- a/usr/src/lib/brand/sn1/sn1_brand/common/sn1_brand.c +++ b/usr/src/lib/brand/sn1/sn1_brand/common/sn1_brand.c @@ -116,7 +116,6 @@ IN_KERNEL_SYSCALL(getuid, SYS_getuid) /* 24 */ IN_KERNEL_SYSCALL(times, SYS_times) /* 43 */ IN_KERNEL_SYSCALL(getgid, SYS_getgid) /* 47 */ IN_KERNEL_SYSCALL(utssys, SYS_utssys) /* 57 */ -IN_KERNEL_SYSCALL(readlink, SYS_readlink) /* 90 */ IN_KERNEL_SYSCALL(waitid, SYS_waitid) /* 107 */ /* @@ -223,7 +222,7 @@ brand_sysent_table_t brand_sysent_table[] = { NOSYS, /* 87 */ NOSYS, /* 88 */ NOSYS, /* 89 */ - EMULATE(sn1_readlink, 3 | RV_DEFAULT), /* 90 */ + NOSYS, /* 90 */ NOSYS, /* 91 */ NOSYS, /* 92 */ NOSYS, /* 93 */ diff --git a/usr/src/lib/brand/solaris10/s10_brand/common/s10_brand.c b/usr/src/lib/brand/solaris10/s10_brand/common/s10_brand.c index dca4fc4e90..f179a3d44f 100644 --- a/usr/src/lib/brand/solaris10/s10_brand/common/s10_brand.c +++ b/usr/src/lib/brand/solaris10/s10_brand/common/s10_brand.c @@ -1867,13 +1867,13 @@ brand_sysent_table_t brand_sysent_table[] = { NOSYS, /* 6 */ EMULATE(s10_wait, 0 | RV_32RVAL2), /* 7 */ EMULATE(s10_creat, 2 | RV_DEFAULT), /* 8 */ - NOSYS, /* 9 */ + EMULATE(s10_link, 2 | RV_DEFAULT), /* 9 */ EMULATE(s10_unlink, 1 | RV_DEFAULT), /* 10 */ EMULATE(s10_exec, 2 | RV_DEFAULT), /* 11 */ NOSYS, /* 12 */ NOSYS, /* 13 */ - NOSYS, /* 14 */ - NOSYS, /* 15 */ + EMULATE(s10_mknod, 3 | RV_DEFAULT), /* 14 */ + EMULATE(s10_chmod, 2 | RV_DEFAULT), /* 15 */ EMULATE(s10_chown, 3 | RV_DEFAULT), /* 16 */ NOSYS, /* 17 */ EMULATE(s10_stat, 2 | RV_DEFAULT), /* 18 */ @@ -1938,7 +1938,7 @@ brand_sysent_table_t brand_sysent_table[] = { NOSYS, /* 77 */ NOSYS, /* 78 */ EMULATE(s10_rmdir, 1 | RV_DEFAULT), /* 79 */ - NOSYS, /* 80 */ + EMULATE(s10_mkdir, 2 | RV_DEFAULT), /* 80 */ EMULATE(s10_getdents, 3 | RV_DEFAULT), /* 81 */ NOSYS, /* 82 */ NOSYS, /* 83 */ @@ -1947,11 +1947,11 @@ brand_sysent_table_t brand_sysent_table[] = { NOSYS, /* 86 */ EMULATE(s10_poll, 3 | RV_DEFAULT), /* 87 */ EMULATE(s10_lstat, 2 | RV_DEFAULT), /* 88 */ - NOSYS, /* 89 */ - NOSYS, /* 90 */ + EMULATE(s10_symlink, 2 | RV_DEFAULT), /* 89 */ + EMULATE(s10_readlink, 3 | RV_DEFAULT), /* 90 */ NOSYS, /* 91 */ NOSYS, /* 92 */ - NOSYS, /* 93 */ + EMULATE(s10_fchmod, 2 | RV_DEFAULT), /* 93 */ EMULATE(s10_fchown, 3 | RV_DEFAULT), /* 94 */ EMULATE(s10_sigprocmask, 3 | RV_DEFAULT), /* 95 */ EMULATE(s10_sigsuspend, 1 | RV_DEFAULT), /* 96 */ diff --git a/usr/src/lib/brand/solaris10/s10_brand/common/s10_deleted.c b/usr/src/lib/brand/solaris10/s10_brand/common/s10_deleted.c index d75413a22f..020cf9b738 100644 --- a/usr/src/lib/brand/solaris10/s10_brand/common/s10_deleted.c +++ b/usr/src/lib/brand/solaris10/s10_brand/common/s10_deleted.c @@ -204,12 +204,26 @@ s10_lwp_sema_wait(sysret_t *rval, void *sp) sp, NULL, 0)); } +int +s10_chmod(sysret_t *rval, const char *name, mode_t mode) +{ + return (__systemcall(rval, SYS_fchmodat + 1024, + AT_FDCWD, name, mode, 0)); +} + +int +s10_fchmod(sysret_t *rval, int filedes, mode_t mode) +{ + return (__systemcall(rval, SYS_fchmodat + 1024, + filedes, NULL, mode, 0)); +} + static int s10_fchownat(sysret_t *rval, - int fd, const char *name, uid_t uid, gid_t gid, int flags) + int fd, const char *name, uid_t uid, gid_t gid, int flag) { return (__systemcall(rval, SYS_fchownat + 1024, - fd, name, uid, gid, flags)); + fd, name, uid, gid, flag)); } int @@ -233,6 +247,27 @@ s10_fchown(sysret_t *rval, int filedes, uid_t uid, gid_t gid) filedes, NULL, uid, gid, 0)); } +int +s10_mkdir(sysret_t *rval, const char *dname, int dmode) +{ + return (__systemcall(rval, SYS_mkdirat + 1024, + AT_FDCWD, dname, dmode)); +} + +int +s10_mknod(sysret_t *rval, const char *fname, int fmode, dev_t dev) +{ + return (__systemcall(rval, SYS_mknodat + 1024, + AT_FDCWD, fname, fmode, dev)); +} + +int +s10_link(sysret_t *rval, const char *path1, const char *path2) +{ + return (__systemcall(rval, SYS_linkat + 1024, + AT_FDCWD, path1, AT_FDCWD, path2, 0)); +} + static int s10_unlinkat(sysret_t *rval, int fd, const char *name, int flags) { @@ -269,6 +304,20 @@ s10_rename(sysret_t *rval, const char *oldname, const char *newname) AT_FDCWD, oldname, AT_FDCWD, newname)); } +int +s10_symlink(sysret_t *rval, const char *path1, const char *path2) +{ + return (__systemcall(rval, SYS_symlinkat + 1024, + path1, AT_FDCWD, path2)); +} + +int +s10_readlink(sysret_t *rval, const char *path, char *buf, size_t bufsize) +{ + return (__systemcall(rval, SYS_readlinkat + 1024, + AT_FDCWD, path, buf, bufsize)); +} + static int s10_faccessat(sysret_t *rval, int fd, const char *fname, int amode, int flag) { @@ -409,7 +458,8 @@ s10_xmknod(sysret_t *rval, int version, const char *path, #else if (version != _MKNOD_VER) return (EINVAL); - return (__systemcall(rval, SYS_mknod + 1024, path, mode, dev)); + return (__systemcall(rval, SYS_mknodat + 1024, + AT_FDCWD, path, mode, dev)); #endif } diff --git a/usr/src/lib/brand/solaris10/s10_brand/sys/s10_misc.h b/usr/src/lib/brand/solaris10/s10_brand/sys/s10_misc.h index d68833060f..214bf87b26 100644 --- a/usr/src/lib/brand/solaris10/s10_brand/sys/s10_misc.h +++ b/usr/src/lib/brand/solaris10/s10_brand/sys/s10_misc.h @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -42,10 +43,17 @@ extern int s10_lstat64(); extern int s10_fstat64(); extern int s10_open(); extern int s10_open64(); +extern int s10_chmod(); +extern int s10_fchmod(); extern int s10_chown(); extern int s10_lchown(); extern int s10_fchown(); +extern int s10_mkdir(); +extern int s10_mknod(); +extern int s10_link(); extern int s10_unlink(); +extern int s10_symlink(); +extern int s10_readlink(); extern int s10_rmdir(); extern int s10_rename(); extern int s10_access(); diff --git a/usr/src/lib/libbc/libc/sys/4.2/chmod.c b/usr/src/lib/libbc/libc/sys/4.2/chmod.c index f5992d7a00..ea98fb387a 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/chmod.c +++ b/usr/src/lib/libbc/libc/sys/4.2/chmod.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,18 +18,17 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - -# include "chkpath.h" +#include "chkpath.h" +#include <sys/fcntl.h> int -chmod(char *s, int m) +chmod(char *s, mode_t m) { - CHKNULL(s); - return (_syscall(SYS_chmod, s, m)); + CHKNULL(s); + return (_syscall(SYS_fchmodat, AT_FDCWD, s, m, 0)); } diff --git a/usr/src/lib/libbc/libc/sys/4.2/link.c b/usr/src/lib/libbc/libc/sys/4.2/link.c index 8b060e4774..a48eca7975 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/link.c +++ b/usr/src/lib/libbc/libc/sys/4.2/link.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,19 +18,18 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "chkpath.h" +#include <sys/fcntl.h> int link(char *a, char *b) { - CHKNULL(a); - CHKNULL(b); - return (_syscall(SYS_link, a, b)); + CHKNULL(a); + CHKNULL(b); + return (_syscall(SYS_linkat, AT_FDCWD, a, AT_FDCWD, b, 0)); } diff --git a/usr/src/lib/libbc/libc/sys/4.2/mkdir.c b/usr/src/lib/libbc/libc/sys/4.2/mkdir.c index 97925363e1..23bed9c6c0 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/mkdir.c +++ b/usr/src/lib/libbc/libc/sys/4.2/mkdir.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,18 +18,17 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "chkpath.h" +#include <sys/fcntl.h> int -mkdir(char *p, int m) +mkdir(char *p, mode_t m) { - CHKNULL(p); - return (_syscall(SYS_mkdir, p, m)); + CHKNULL(p); + return (_syscall(SYS_mkdirat, AT_FDCWD, p, m)); } diff --git a/usr/src/lib/libbc/libc/sys/4.2/mknod.c b/usr/src/lib/libbc/libc/sys/4.2/mknod.c index f69c4d6d2c..b06033270d 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/mknod.c +++ b/usr/src/lib/libbc/libc/sys/4.2/mknod.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,18 +18,17 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "chkpath.h" +#include <sys/fcntl.h> int mknod(char *p, int m, int d) { - CHKNULL(p); - return (_syscall(SYS_mknod, p, m, d)); + CHKNULL(p); + return (_syscall(SYS_mknodat, AT_FDCWD, p, m, d)); } diff --git a/usr/src/lib/libbc/libc/sys/4.2/readlink.c b/usr/src/lib/libbc/libc/sys/4.2/readlink.c index ff8f566f23..4c24ef8f75 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/readlink.c +++ b/usr/src/lib/libbc/libc/sys/4.2/readlink.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,18 +18,17 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "chkpath.h" +#include <sys/fcntl.h> int readlink(char *p, char *b, int s) { - CHKNULL(p); - return (_syscall(SYS_readlink, p, b, s)); + CHKNULL(p); + return (_syscall(SYS_readlinkat, AT_FDCWD, p, b, s)); } diff --git a/usr/src/lib/libbc/libc/sys/4.2/symlink.c b/usr/src/lib/libbc/libc/sys/4.2/symlink.c index c9bf39cc17..622832a703 100644 --- a/usr/src/lib/libbc/libc/sys/4.2/symlink.c +++ b/usr/src/lib/libbc/libc/sys/4.2/symlink.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,19 +18,18 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "chkpath.h" +#include <sys/fcntl.h> int symlink(char *t, char *f) { - CHKNULL(t); - CHKNULL(f); - return (_syscall(SYS_symlink, t, f)); + CHKNULL(t); + CHKNULL(f); + return (_syscall(SYS_symlinkat, t, AT_FDCWD, f)); } diff --git a/usr/src/lib/libbc/libc/sys/common/syscall.c b/usr/src/lib/libbc/libc/sys/common/syscall.c index 83079878f8..945143e40e 100644 --- a/usr/src/lib/libbc/libc/sys/common/syscall.c +++ b/usr/src/lib/libbc/libc/sys/common/syscall.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <errno.h> @@ -37,9 +36,9 @@ int syscallnum[190] = { SYS_syscall, SYS_exit, -1 /*fork1*/, SYS_read, SYS_write, -1 /*open*/, SYS_close, - -1, -1 /*creat*/, SYS_link, -1 /*unlink*/, - -1, SYS_chdir, 0, SYS_mknod, - SYS_chmod, -1 /*lchown*/, 0, 0, + -1, -1 /*creat*/, -1 /*link*/, -1 /*unlink*/, + -1, SYS_chdir, 0, -1 /*mknod*/, + -1 /*chmod*/, -1 /*lchown*/, 0, 0, SYS_lseek, SYS_getpid, 0, 0, 0, SYS_getuid, 0, 0, 0, 0, 0, 0, @@ -49,7 +48,7 @@ int syscallnum[190] = { SYS_syscall, SYS_exit, -1 /*fork1*/, 0, SYS_profil, 0, 0, SYS_getgid, 0, 0, 0, SYS_acct, 0, -1, SYS_ioctl, - -1 /*reboot*/, 0, SYS_symlink, SYS_readlink, + -1 /*reboot*/, 0, -1 /*symlink*/, -1 /*readlink*/, SYS_execve, SYS_umask, SYS_chroot, -1 /*fstat*/, 0, -1/*getpagesize*/,-1, 0, 0, 0, -1, -1, @@ -66,10 +65,10 @@ int syscallnum[190] = { SYS_syscall, SYS_exit, -1 /*fork1*/, -1 /*sigpause*/, -1 /*sigstack*/, -1 /*recvmsg*/, -1 /*sendmsg*/, -1 /*vtrace*/, SYS_gettimeofday, -1 /*getrusage*/, -1 /*getsockopt*/, 0, SYS_readv, SYS_writev, -1 /*settimeofday*/, - -1 /*fchown*/, SYS_fchmod, -1 /*recvfrom*/, -1 /*setreuid*/, + -1 /*fchown*/, -1 /*fchmod*/, -1 /*recvfrom*/, -1 /*setreuid*/, -1 /*getregid*/, -1 /*rename*/, -1 /*truncate*/, -1 /*ftruncate*/, -1 /*flock*/, 0, -1 /*sendto*/, -1 /*shutdown*/, - -1 /*socketpair*/,SYS_mkdir, -1 /*rmdir*/, -1 /*utimes*/, + -1 /*socketpair*/, -1 /*mkdir*/, -1 /*rmdir*/, -1 /*utimes*/, 0, SYS_adjtime, -1 /*getpeername*/,-1 /*gethostid*/, 0, SYS_getrlimit, SYS_setrlimit, -1 /*killpg*/, 0, 0, 0, -1/*getsockname*/, @@ -474,6 +473,11 @@ syscall(int sysnum, ...) i3 = va_arg(ap, int); va_end(ap); return (poll(c1, i2, i3)); + case XSYS_fchmod: + i1 = va_arg(ap, int); + i2 = va_arg(ap, int); + va_end(ap); + return (fchmod(i1, i2)); case XSYS_fchown: i1 = va_arg(ap, int); i2 = va_arg(ap, int); @@ -616,7 +620,6 @@ syscall(int sysnum, ...) case XSYS_adjtime: case XSYS_exit: case XSYS_fchdir: - case XSYS_fchmod: case XSYS_fchroot: case XSYS_getgid: case XSYS_getitimer: diff --git a/usr/src/lib/libbc/libc/sys/sys5/chmod.c b/usr/src/lib/libbc/libc/sys/sys5/chmod.c index 0116dc7aab..32840d46fb 100644 --- a/usr/src/lib/libbc/libc/sys/sys5/chmod.c +++ b/usr/src/lib/libbc/libc/sys/sys5/chmod.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,17 +18,16 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/syscall.h> +#include <sys/fcntl.h> int -chmod(char *s, int m) +chmod(char *s, mode_t m) { - return (_syscall(SYS_chmod, s, m)); + return (_syscall(SYS_fchmodat, AT_FDCWD, s, m, 0)); } diff --git a/usr/src/lib/libbc/libc/sys/sys5/link.c b/usr/src/lib/libbc/libc/sys/sys5/link.c index 5025510281..85ecd49af3 100644 --- a/usr/src/lib/libbc/libc/sys/sys5/link.c +++ b/usr/src/lib/libbc/libc/sys/sys5/link.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,17 +18,16 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/syscall.h> +#include <sys/fcntl.h> int link(char *a, char *b) { - return (_syscall(SYS_link, a, b)); + return (_syscall(SYS_linkat, AT_FDCWD, a, AT_FDCWD, b, 0)); } diff --git a/usr/src/lib/libbc/libc/sys/sys5/mkdir.c b/usr/src/lib/libbc/libc/sys/sys5/mkdir.c index 87fa580398..5f0c8106ea 100644 --- a/usr/src/lib/libbc/libc/sys/sys5/mkdir.c +++ b/usr/src/lib/libbc/libc/sys/sys5/mkdir.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,17 +18,16 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/syscall.h> +#include <sys/fcntl.h> int -mkdir(char *p, int m) +mkdir(char *p, mode_t m) { - return (_syscall(SYS_mkdir, p, m)); + return (_syscall(SYS_mkdirat, AT_FDCWD, p, m)); } diff --git a/usr/src/lib/libbc/libc/sys/sys5/readlink.c b/usr/src/lib/libbc/libc/sys/sys5/readlink.c index 48e3a692be..9007d4065a 100644 --- a/usr/src/lib/libbc/libc/sys/sys5/readlink.c +++ b/usr/src/lib/libbc/libc/sys/sys5/readlink.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,17 +18,16 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/syscall.h> +#include <sys/fcntl.h> int readlink(char *p, char *b, int s) { - return (_syscall(SYS_readlink, p, b, s)); + return (_syscall(SYS_readlinkat, AT_FDCWD, p, b, s)); } diff --git a/usr/src/lib/libbc/libc/sys/sys5/symlink.c b/usr/src/lib/libbc/libc/sys/sys5/symlink.c index 666b3b44e2..cf96a6cbd6 100644 --- a/usr/src/lib/libbc/libc/sys/sys5/symlink.c +++ b/usr/src/lib/libbc/libc/sys/sys5/symlink.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,17 +18,16 @@ * * CDDL HEADER END */ + /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/syscall.h> +#include <sys/fcntl.h> int symlink(char *t, char *f) { - return (_syscall(SYS_symlink, t, f)); + return (_syscall(SYS_symlinkat, t, AT_FDCWD, f)); } diff --git a/usr/src/lib/libbc/sparc/Makefile b/usr/src/lib/libbc/sparc/Makefile index a0c3098dfc..36cce42c3a 100644 --- a/usr/src/lib/libbc/sparc/Makefile +++ b/usr/src/lib/libbc/sparc/Makefile @@ -125,7 +125,7 @@ sprintf.o vfprintf.o vprintf.o vsprintf.o SYSCOM=\ _access.o acct.o adjtime.o close.o _creat.o dup.o dup2.o \ -fchdir.o fchmod.o fchroot.o \ +fchdir.o fchroot.o \ fdlist.o flock.o fpathconf.o fsync.o ftruncate.o getdents.o \ getdtablesize.o getgid.o getitimer.o getpid.o gettimeofday.o \ getuid.o ioctl.o kill.o lseek.o mincore.o mprotect.o munmap.o\ @@ -182,7 +182,7 @@ YP= yp_bind.o YP= yp_bind.o PSEUDO_SRCS= adjtime.s fchdir.s \ -fchmod.s fchroot.s \ +fchroot.s \ fpathconf.s getitimer.s getpid.s \ mincore.s mprotect.s munmap.s \ profil.s setitimer.s \ diff --git a/usr/src/lib/libbsm/audit_event.txt b/usr/src/lib/libbsm/audit_event.txt index 06aa34a2fa..4317d3cb78 100644 --- a/usr/src/lib/libbsm/audit_event.txt +++ b/usr/src/lib/libbsm/audit_event.txt @@ -183,6 +183,9 @@ 114:AUE_ASYNC_DAEMON_EXIT:async_daemon(2) exited:no 115:AUE_NFSSVC_EXIT:nfssvc(2) exited:no 116:AUE_PFEXEC:execve(2) with pfexec enabled:ps,ex,ua,as +117:AUE_OPEN_S:open(2) - search:fr +118:AUE_OPEN_E:open(2) - exec:fr + 130:AUE_GETAUID:getauid(2):aa 131:AUE_SETAUID:setauid(2):aa 132:AUE_GETAUDIT:getaudit(2):aa diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile index 2176c1da01..8ece7c4add 100644 --- a/usr/src/lib/libc/amd64/Makefile +++ b/usr/src/lib/libc/amd64/Makefile @@ -18,7 +18,6 @@ # # CDDL HEADER END # - # # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. # @@ -173,7 +172,6 @@ COMSYSOBJS= \ alarm.o \ brk.o \ chdir.o \ - chmod.o \ chroot.o \ cladm.o \ close.o \ @@ -181,7 +179,6 @@ COMSYSOBJS= \ exit.o \ facl.o \ fchdir.o \ - fchmod.o \ fchroot.o \ fdsync.o \ fpathconf.o \ @@ -206,14 +203,11 @@ COMSYSOBJS= \ ioctl.o \ kaio.o \ kill.o \ - link.o \ llseek.o \ lseek.o \ mmapobjsys.o \ memcntl.o \ mincore.o \ - mkdir.o \ - mknod.o \ mmap.o \ modctl.o \ mount.o \ @@ -236,7 +230,6 @@ COMSYSOBJS= \ putpmsg.o \ pwrite.o \ read.o \ - readlink.o \ readv.o \ resolvepath.o \ seteguid.o \ @@ -253,7 +246,6 @@ COMSYSOBJS= \ statfs.o \ statvfs.o \ stty.o \ - symlink.o \ sync.o \ sysconfig.o \ sysfs.o \ @@ -770,6 +762,7 @@ PORTSYS= \ access.o \ acctctl.o \ bsd_signal.o \ + chmod.o \ chown.o \ corectl.o \ exacctsys.o \ @@ -782,13 +775,15 @@ PORTSYS= \ inst_sync.o \ issetugid.o \ label.o \ - libc_link.o \ + link.o \ lockf.o \ lwp.o \ lwp_cond.o \ lwp_rwlock.o \ lwp_sigmask.o \ meminfosys.o \ + mkdir.o \ + mknod.o \ msgsys.o \ nfssys.o \ open.o \ @@ -797,6 +792,7 @@ PORTSYS= \ ppriv.o \ psetsys.o \ rctlsys.o \ + readlink.o \ rename.o \ sbrk.o \ semsys.o \ @@ -809,6 +805,7 @@ PORTSYS= \ sigpending.o \ sigstack.o \ stat.o \ + symlink.o \ tasksys.o \ time.o \ time_util.o \ diff --git a/usr/src/lib/libc/common/sys/mknod.s b/usr/src/lib/libc/common/sys/mknod.s deleted file mode 100644 index 0d7733e7ff..0000000000 --- a/usr/src/lib/libc/common/sys/mknod.s +++ /dev/null @@ -1,43 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - - -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - .file "mknod.s" - -/* C library -- mknod */ -/* int mknod(const char *path, mode_t mode, dev_t dev); */ - -#include <sys/asm_linkage.h> - - ANSI_PRAGMA_WEAK(mknod,function) - -#include "SYS.h" - - SYSCALL_RVAL1(mknod) - RETC - SET_SIZE(mknod) diff --git a/usr/src/lib/libc/common/sys/readlink.s b/usr/src/lib/libc/common/sys/readlink.s deleted file mode 100644 index 2ec6e5a886..0000000000 --- a/usr/src/lib/libc/common/sys/readlink.s +++ /dev/null @@ -1,45 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - - -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - .file "readlink.s" - -/* - * C library -- readlink - * ssize_t readlink(const char *path, char *buf, size_t bufsize); - */ - -#include <sys/asm_linkage.h> - - ANSI_PRAGMA_WEAK(readlink,function) - -#include "SYS.h" - - SYSCALL_RVAL1(readlink) - RET - SET_SIZE(readlink) diff --git a/usr/src/lib/libc/common/sys/symlink.s b/usr/src/lib/libc/common/sys/symlink.s deleted file mode 100644 index d46e48f1c4..0000000000 --- a/usr/src/lib/libc/common/sys/symlink.s +++ /dev/null @@ -1,43 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - - -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - .file "symlink.s" - -/* C library -- symlink */ -/* int symlink(const char *name1, const char *name2) */ - -#include <sys/asm_linkage.h> - - ANSI_PRAGMA_WEAK(symlink,function) - -#include "SYS.h" - - SYSCALL_RVAL1(symlink) - RETC - SET_SIZE(symlink) diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com index 50d06a4e4f..55a006e315 100644 --- a/usr/src/lib/libc/i386/Makefile.com +++ b/usr/src/lib/libc/i386/Makefile.com @@ -18,7 +18,6 @@ # # CDDL HEADER END # - # # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. # @@ -195,7 +194,6 @@ COMSYSOBJS= \ alarm.o \ brk.o \ chdir.o \ - chmod.o \ chroot.o \ cladm.o \ close.o \ @@ -203,7 +201,6 @@ COMSYSOBJS= \ exit.o \ facl.o \ fchdir.o \ - fchmod.o \ fchroot.o \ fdsync.o \ fpathconf.o \ @@ -228,14 +225,11 @@ COMSYSOBJS= \ ioctl.o \ kaio.o \ kill.o \ - link.o \ llseek.o \ lseek.o \ mmapobjsys.o \ memcntl.o \ mincore.o \ - mkdir.o \ - mknod.o \ mmap.o \ modctl.o \ mount.o \ @@ -258,7 +252,6 @@ COMSYSOBJS= \ putpmsg.o \ pwrite.o \ read.o \ - readlink.o \ readv.o \ resolvepath.o \ seteguid.o \ @@ -275,7 +268,6 @@ COMSYSOBJS= \ statfs.o \ statvfs.o \ stty.o \ - symlink.o \ sync.o \ sysconfig.o \ sysfs.o \ @@ -808,6 +800,7 @@ PORTSYS= \ access.o \ acctctl.o \ bsd_signal.o \ + chmod.o \ chown.o \ corectl.o \ exacctsys.o \ @@ -820,13 +813,15 @@ PORTSYS= \ inst_sync.o \ issetugid.o \ label.o \ - libc_link.o \ + link.o \ lockf.o \ lwp.o \ lwp_cond.o \ lwp_rwlock.o \ lwp_sigmask.o \ meminfosys.o \ + mkdir.o \ + mknod.o \ msgsys.o \ nfssys.o \ open.o \ @@ -835,6 +830,7 @@ PORTSYS= \ ppriv.o \ psetsys.o \ rctlsys.o \ + readlink.o \ rename.o \ sbrk.o \ semsys.o \ @@ -847,6 +843,7 @@ PORTSYS= \ sigpending.o \ sigstack.o \ stat.o \ + symlink.o \ tasksys.o \ time.o \ time_util.o \ diff --git a/usr/src/lib/libc/port/gen/mkfifo.c b/usr/src/lib/libc/port/gen/mkfifo.c index eb73e03184..ac2897c92a 100644 --- a/usr/src/lib/libc/port/gen/mkfifo.c +++ b/usr/src/lib/libc/port/gen/mkfifo.c @@ -20,28 +20,31 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * mkfifo(3c) - create a named pipe (FIFO). This code provides * a POSIX mkfifo function. - * */ -#pragma weak _mkfifo = mkfifo - #include "lint.h" #include <sys/types.h> #include <sys/stat.h> int +mkfifoat(int fd, const char *path, mode_t mode) +{ + mode &= 0777; /* only allow file access permissions */ + mode |= S_IFIFO; /* creating a FIFO */ + return (mknodat(fd, path, mode, 0)); +} + +#pragma weak _mkfifo = mkfifo +int mkfifo(const char *path, mode_t mode) { mode &= 0777; /* only allow file access permissions */ diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers index a3dae49082..ed3f10dd05 100644 --- a/usr/src/lib/libc/port/mapfile-vers +++ b/usr/src/lib/libc/port/mapfile-vers @@ -146,6 +146,7 @@ $endif err; errx; faccessat; + fchmodat; fdatasync; fgetattr; forkallx; @@ -155,8 +156,12 @@ $endif htonl; htonll; htons; + linkat; lio_listio; + mkdirat; mkdtemp; + mkfifoat; + mknodat; mkstemps; mmapobj; mq_close; @@ -187,6 +192,7 @@ $endif pthread_mutexattr_getrobust; pthread_mutexattr_setrobust; pthread_mutex_consistent; + readlinkat; sched_getparam; sched_get_priority_max; sched_get_priority_min; @@ -215,6 +221,7 @@ $endif sigwaitinfo; strnlen; strsep; + symlinkat; thr_keycreate_once; timer_create; timer_delete; diff --git a/usr/src/lib/libc/common/sys/mkdir.s b/usr/src/lib/libc/port/sys/chmod.c index 1efbfc9081..90266e55b1 100644 --- a/usr/src/lib/libc/common/sys/mkdir.s +++ b/usr/src/lib/libc/port/sys/chmod.c @@ -18,26 +18,43 @@ * * CDDL HEADER END */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. */ - .file "mkdir.s" - -/* C library -- mkdir */ -/* int mkdir (const char *path, mode_t mode); */ - -#include <sys/asm_linkage.h> - - ANSI_PRAGMA_WEAK(mkdir,function) - -#include "SYS.h" - - SYSCALL_RVAL1(mkdir) - RET - SET_SIZE(mkdir) +#include "lint.h" +#include <stdio.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/syscall.h> +#include <sys/fcntl.h> + +int +fchmodat(int fd, const char *path, mode_t mode, int flag) +{ + return (syscall(SYS_fchmodat, fd, path, mode, flag)); +} + +#pragma weak _chmod = chmod +int +chmod(const char *path, mode_t mode) +{ +#if defined(_RETAIN_OLD_SYSCALLS) + return (syscall(SYS_chmod, path, mode)); +#else + return (fchmodat(AT_FDCWD, path, mode, 0)); +#endif +} + +#pragma weak _fchmod = fchmod +int +fchmod(int fd, mode_t mode) +{ +#if defined(_RETAIN_OLD_SYSCALLS) + return (syscall(SYS_fchmod, fd, mode)); +#else + return (fchmodat(fd, NULL, mode, 0)); +#endif +} diff --git a/usr/src/lib/libc/port/sys/libc_link.c b/usr/src/lib/libc/port/sys/link.c index f0f4356871..dd1d64240e 100644 --- a/usr/src/lib/libc/port/sys/libc_link.c +++ b/usr/src/lib/libc/port/sys/link.c @@ -20,30 +20,26 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - -#pragma weak _link = link - #include "lint.h" -#include <stdlib.h> -#include <errno.h> #include <unistd.h> -#include <limits.h> +#include <fcntl.h> +#include <sys/syscall.h> extern int __xpg4; /* defined in port/gen/xpg4.c; 0 if not xpg4/xpg4v2 */ -extern int __link(const char *existing, const char *new); - int -link(const char *existing, const char *new) +linkat(int fd1, const char *path1, int fd2, const char *path2, int flag) { - int sz; - char linkbuf[PATH_MAX + 1]; + return (syscall(SYS_linkat, fd1, path1, fd2, path2, flag)); +} +#pragma weak _link = link +int +link(const char *path1, const char *path2) +{ /* * XPG4v2 link() requires that the link count of a symbolic * link target be updated rather than the link itself. This @@ -56,11 +52,13 @@ link(const char *existing, const char *new) * non-XPG4 based environments. For a more detailed discussion, * see bug 1256170. */ - if (__xpg4 != 0) { - if ((sz = resolvepath(existing, linkbuf, PATH_MAX)) == -1) - return (-1); - linkbuf[sz] = '\0'; - existing = linkbuf; - } - return (__link(existing, new)); + if (__xpg4 != 0) + return (linkat(AT_FDCWD, path1, AT_FDCWD, path2, + AT_SYMLINK_FOLLOW)); + +#if defined(_RETAIN_OLD_SYSCALLS) + return (syscall(SYS_link, path1, path2)); +#else + return (linkat(AT_FDCWD, path1, AT_FDCWD, path2, 0)); +#endif } diff --git a/usr/src/lib/libc/common/sys/chmod.s b/usr/src/lib/libc/port/sys/mkdir.c index e5175fafcb..49f60111c4 100644 --- a/usr/src/lib/libc/common/sys/chmod.s +++ b/usr/src/lib/libc/port/sys/mkdir.c @@ -18,26 +18,29 @@ * * CDDL HEADER END */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. */ - .file "chmod.s" - -/* C library -- chmod */ -/* int chmod(char *path, mode_t mode) */ - -#include <sys/asm_linkage.h> - - ANSI_PRAGMA_WEAK(chmod,function) - -#include "SYS.h" - - SYSCALL_RVAL1(chmod) - RETC - SET_SIZE(chmod) +#include "lint.h" +#include <sys/syscall.h> +#include <sys/stat.h> +#include <sys/fcntl.h> + +int +mkdirat(int fd, const char *path, mode_t mode) +{ + return (syscall(SYS_mkdirat, fd, path, mode)); +} + +#pragma weak _mkdir = mkdir +int +mkdir(const char *path, mode_t mode) +{ +#if defined(_RETAIN_OLD_SYSCALLS) + return (syscall(SYS_mkdir, path, mode)); +#else + return (mkdirat(AT_FDCWD, path, mode)); +#endif +} diff --git a/usr/src/lib/libc/common/sys/link.s b/usr/src/lib/libc/port/sys/mknod.c index cbc03892b5..df179cfec2 100644 --- a/usr/src/lib/libc/common/sys/link.s +++ b/usr/src/lib/libc/port/sys/mknod.c @@ -20,20 +20,27 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ +#include "lint.h" +#include <sys/syscall.h> +#include <sys/stat.h> +#include <sys/fcntl.h> - .file "link.s" +int +mknodat(int fd, const char *path, mode_t mode, dev_t dev) +{ + return (syscall(SYS_mknodat, fd, path, mode, dev)); +} -/* C library -- link */ -/* int link (const char *path1, const char *path2); */ - -#include "SYS.h" - - SYSCALL2_RVAL1(__link,link) - RETC - SET_SIZE(__link) +#pragma weak _mknod = mknod +int +mknod(const char *path, mode_t mode, dev_t dev) +{ +#if defined(_RETAIN_OLD_SYSCALLS) + return (syscall(SYS_mknod, path, mode, dev)); +#else + return (mknodat(AT_FDCWD, path, mode, dev)); +#endif +} diff --git a/usr/src/lib/libc/port/sys/readlink.c b/usr/src/lib/libc/port/sys/readlink.c new file mode 100644 index 0000000000..fc58441b53 --- /dev/null +++ b/usr/src/lib/libc/port/sys/readlink.c @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include "lint.h" +#include <sys/syscall.h> +#include <sys/unistd.h> +#include <sys/fcntl.h> + +ssize_t +readlinkat(int fd, const char *path, char *buf, size_t bufsize) +{ + sysret_t rval; + int error; + + error = __systemcall(&rval, SYS_readlinkat, fd, path, buf, bufsize); + if (error) + (void) __set_errno(error); + return ((ssize_t)rval.sys_rval1); +} + +#pragma weak _readlink = readlink +ssize_t +readlink(const char *path, char *buf, size_t bufsize) +{ +#if defined(_RETAIN_OLD_SYSCALLS) + sysret_t rval; + int error; + + error = __systemcall(&rval, SYS_readlink, path, buf, bufsize); + if (error) + (void) __set_errno(error); + return ((ssize_t)rval.sys_rval1); +#else + return (readlinkat(AT_FDCWD, path, buf, bufsize)); +#endif +} diff --git a/usr/src/lib/libc/common/sys/fchmod.s b/usr/src/lib/libc/port/sys/symlink.c index dc40164077..59a6ece2c4 100644 --- a/usr/src/lib/libc/common/sys/fchmod.s +++ b/usr/src/lib/libc/port/sys/symlink.c @@ -18,26 +18,29 @@ * * CDDL HEADER END */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. */ - .file "fchmod.s" - -/* C library -- fchmod */ -/* int fchmod(int fildes, mode_t mode) */ - -#include <sys/asm_linkage.h> - - ANSI_PRAGMA_WEAK(fchmod,function) - -#include "SYS.h" - - SYSCALL_RVAL1(fchmod) - RETC - SET_SIZE(fchmod) +#include "lint.h" +#include <sys/syscall.h> +#include <sys/unistd.h> +#include <sys/fcntl.h> + +int +symlinkat(const char *path1, int fd, const char *path2) +{ + return (syscall(SYS_symlinkat, path1, fd, path2)); +} + +#pragma weak _symlink = symlink +int +symlink(const char *path1, const char *path2) +{ +#if defined(_RETAIN_OLD_SYSCALLS) + return (syscall(SYS_symlink, path1, path2)); +#else + return (symlinkat(path1, AT_FDCWD, path2)); +#endif +} diff --git a/usr/src/lib/libc/sparc/Makefile.com b/usr/src/lib/libc/sparc/Makefile.com index b03c067933..84c888d0fc 100644 --- a/usr/src/lib/libc/sparc/Makefile.com +++ b/usr/src/lib/libc/sparc/Makefile.com @@ -18,9 +18,8 @@ # # CDDL HEADER END # - # -# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. # LIBCDIR= $(SRC)/lib/libc @@ -213,7 +212,6 @@ COMSYSOBJS= \ alarm.o \ brk.o \ chdir.o \ - chmod.o \ chroot.o \ cladm.o \ close.o \ @@ -221,7 +219,6 @@ COMSYSOBJS= \ exit.o \ facl.o \ fchdir.o \ - fchmod.o \ fchroot.o \ fdsync.o \ fpathconf.o \ @@ -246,13 +243,10 @@ COMSYSOBJS= \ ioctl.o \ kaio.o \ kill.o \ - link.o \ llseek.o \ lseek.o \ memcntl.o \ mincore.o \ - mkdir.o \ - mknod.o \ mmap.o \ mmapobjsys.o \ modctl.o \ @@ -276,7 +270,6 @@ COMSYSOBJS= \ putpmsg.o \ pwrite.o \ read.o \ - readlink.o \ readv.o \ resolvepath.o \ seteguid.o \ @@ -293,7 +286,6 @@ COMSYSOBJS= \ statfs.o \ statvfs.o \ stty.o \ - symlink.o \ sync.o \ sysconfig.o \ sysfs.o \ @@ -838,6 +830,7 @@ PORTSYS= \ access.o \ acctctl.o \ bsd_signal.o \ + chmod.o \ chown.o \ corectl.o \ exacctsys.o \ @@ -850,13 +843,15 @@ PORTSYS= \ inst_sync.o \ issetugid.o \ label.o \ - libc_link.o \ + link.o \ lockf.o \ lwp.o \ lwp_cond.o \ lwp_rwlock.o \ lwp_sigmask.o \ meminfosys.o \ + mkdir.o \ + mknod.o \ msgsys.o \ nfssys.o \ open.o \ @@ -865,6 +860,7 @@ PORTSYS= \ ppriv.o \ psetsys.o \ rctlsys.o \ + readlink.o \ rename.o \ sbrk.o \ semsys.o \ @@ -877,6 +873,7 @@ PORTSYS= \ sigpending.o \ sigstack.o \ stat.o \ + symlink.o \ tasksys.o \ time.o \ time_util.o \ diff --git a/usr/src/lib/libc/sparcv9/Makefile.com b/usr/src/lib/libc/sparcv9/Makefile.com index 2144a07e17..897e294342 100644 --- a/usr/src/lib/libc/sparcv9/Makefile.com +++ b/usr/src/lib/libc/sparcv9/Makefile.com @@ -18,9 +18,8 @@ # # CDDL HEADER END # - # -# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. # LIBCDIR= $(SRC)/lib/libc @@ -200,7 +199,6 @@ COMSYSOBJS= \ alarm.o \ brk.o \ chdir.o \ - chmod.o \ chroot.o \ cladm.o \ close.o \ @@ -208,7 +206,6 @@ COMSYSOBJS= \ exit.o \ facl.o \ fchdir.o \ - fchmod.o \ fchroot.o \ fdsync.o \ fpathconf.o \ @@ -233,13 +230,10 @@ COMSYSOBJS= \ ioctl.o \ kaio.o \ kill.o \ - link.o \ llseek.o \ lseek.o \ memcntl.o \ mincore.o \ - mkdir.o \ - mknod.o \ mmap.o \ mmapobjsys.o \ modctl.o \ @@ -263,7 +257,6 @@ COMSYSOBJS= \ putpmsg.o \ pwrite.o \ read.o \ - readlink.o \ readv.o \ resolvepath.o \ seteguid.o \ @@ -280,7 +273,6 @@ COMSYSOBJS= \ statfs.o \ statvfs.o \ stty.o \ - symlink.o \ sync.o \ sysconfig.o \ sysfs.o \ @@ -788,6 +780,7 @@ PORTSYS= \ access.o \ acctctl.o \ bsd_signal.o \ + chmod.o \ chown.o \ corectl.o \ exacctsys.o \ @@ -800,13 +793,15 @@ PORTSYS= \ inst_sync.o \ issetugid.o \ label.o \ - libc_link.o \ + link.o \ lockf.o \ lwp.o \ lwp_cond.o \ lwp_rwlock.o \ lwp_sigmask.o \ meminfosys.o \ + mkdir.o \ + mknod.o \ msgsys.o \ nfssys.o \ open.o \ @@ -815,6 +810,7 @@ PORTSYS= \ ppriv.o \ psetsys.o \ rctlsys.o \ + readlink.o \ rename.o \ sbrk.o \ semsys.o \ @@ -827,6 +823,7 @@ PORTSYS= \ sigpending.o \ sigstack.o \ stat.o \ + symlink.o \ tasksys.o \ time.o \ time_util.o \ diff --git a/usr/src/lib/libproc/common/pr_rename.c b/usr/src/lib/libproc/common/pr_rename.c index 7696188111..fe0a2847a4 100644 --- a/usr/src/lib/libproc/common/pr_rename.c +++ b/usr/src/lib/libproc/common/pr_rename.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <stdlib.h> @@ -88,20 +87,34 @@ int pr_link(struct ps_prochandle *Pr, const char *existing, const char *new) { sysret_t rval; - argdes_t argd[2]; + argdes_t argd[5]; argdes_t *adp; int error; if (Pr == NULL) return (link(existing, new)); - adp = &argd[0]; /* existing argument */ + adp = &argd[0]; /* first directory fd argument */ + adp->arg_value = AT_FDCWD; + adp->arg_object = NULL; + adp->arg_type = AT_BYVAL; + adp->arg_inout = AI_INPUT; + adp->arg_size = 0; + + adp++; /* existing argument */ adp->arg_value = 0; adp->arg_object = (void *)existing; adp->arg_type = AT_BYREF; adp->arg_inout = AI_INPUT; adp->arg_size = strlen(existing) + 1; + adp++; /* second directory fd argument */ + adp->arg_value = AT_FDCWD; + adp->arg_object = NULL; + adp->arg_type = AT_BYVAL; + adp->arg_inout = AI_INPUT; + adp->arg_size = 0; + adp++; /* new argument */ adp->arg_value = 0; adp->arg_object = (void *)new; @@ -109,7 +122,14 @@ pr_link(struct ps_prochandle *Pr, const char *existing, const char *new) adp->arg_inout = AI_INPUT; adp->arg_size = strlen(new) + 1; - error = Psyscall(Pr, &rval, SYS_link, 2, &argd[0]); + adp++; /* flag argument */ + adp->arg_value = 0; + adp->arg_object = NULL; + adp->arg_type = AT_BYVAL; + adp->arg_inout = AI_INPUT; + adp->arg_size = 0; + + error = Psyscall(Pr, &rval, SYS_linkat, 5, &argd[0]); if (error) { errno = (error > 0) ? error : ENOSYS; diff --git a/usr/src/lib/libproc/common/proc_names.c b/usr/src/lib/libproc/common/proc_names.c index 96f58363c5..3b7d1e25bf 100644 --- a/usr/src/lib/libproc/common/proc_names.c +++ b/usr/src/lib/libproc/common/proc_names.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <stdio.h> @@ -121,11 +120,11 @@ static const char *const systable[] = { "write", /* 4 */ "open", /* 5 */ "close", /* 6 */ - NULL, /* 7 */ + "linkat", /* 7 */ NULL, /* 8 */ "link", /* 9 */ "unlink", /* 10 */ - NULL, /* 11 */ + "symlinkat", /* 11 */ "chdir", /* 12 */ "time", /* 13 */ "mknod", /* 14 */ @@ -136,7 +135,7 @@ static const char *const systable[] = { "lseek", /* 19 */ "getpid", /* 20 */ "mount", /* 21 */ - NULL, /* 22 */ + "readlinkat", /* 22 */ "setuid", /* 23 */ "getuid", /* 24 */ "stime", /* 25 */ @@ -162,7 +161,7 @@ static const char *const systable[] = { "faccessat", /* 45 */ "setgid", /* 46 */ "getgid", /* 47 */ - "signal", /* 48 */ + "mknodat", /* 48 */ "msgsys", /* 49 */ "sysi86", /* 50 */ "acct", /* 51 */ @@ -215,8 +214,8 @@ static const char *const systable[] = { "sigaction", /* 98 */ "sigpending", /* 99 */ "context", /* 100 */ - NULL, /* 101 */ - NULL, /* 102 */ + "fchmodat", /* 101 */ + "mkdirat", /* 102 */ "statvfs", /* 103 */ "fstatvfs", /* 104 */ "getloadavg", /* 105 */ diff --git a/usr/src/uts/common/brand/sn1/sn1_brand.c b/usr/src/uts/common/brand/sn1/sn1_brand.c index 3d5fc7111a..d61928d578 100644 --- a/usr/src/uts/common/brand/sn1/sn1_brand.c +++ b/usr/src/uts/common/brand/sn1/sn1_brand.c @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -248,7 +249,6 @@ _init(void) sn1_emulation_table[SYS_times] = 1; /* 43 */ sn1_emulation_table[SYS_getgid] = 1; /* 47 */ sn1_emulation_table[SYS_utssys] = 1; /* 57 */ - sn1_emulation_table[SYS_readlink] = 1; /* 90 */ sn1_emulation_table[SYS_waitid] = 1; /* 107 */ sn1_emulation_table[SYS_uname] = 1; /* 135 */ diff --git a/usr/src/uts/common/brand/solaris10/s10_brand.c b/usr/src/uts/common/brand/solaris10/s10_brand.c index 2adf25b453..0cad868679 100644 --- a/usr/src/uts/common/brand/solaris10/s10_brand.c +++ b/usr/src/uts/common/brand/solaris10/s10_brand.c @@ -511,8 +511,11 @@ _init(void) s10_emulation_table[S10_SYS_open] = 1; /* 5 */ s10_emulation_table[S10_SYS_wait] = 1; /* 7 */ s10_emulation_table[S10_SYS_creat] = 1; /* 8 */ + s10_emulation_table[S10_SYS_link] = 1; /* 9 */ s10_emulation_table[S10_SYS_unlink] = 1; /* 10 */ s10_emulation_table[S10_SYS_exec] = 1; /* 11 */ + s10_emulation_table[S10_SYS_mknod] = 1; /* 14 */ + s10_emulation_table[S10_SYS_chmod] = 1; /* 15 */ s10_emulation_table[S10_SYS_chown] = 1; /* 16 */ s10_emulation_table[S10_SYS_stat] = 1; /* 18 */ s10_emulation_table[S10_SYS_umount] = 1; /* 22 */ @@ -527,9 +530,13 @@ _init(void) s10_emulation_table[S10_SYS_issetugid] = 1; /* 75 */ s10_emulation_table[S10_SYS_fsat] = 1; /* 76 */ s10_emulation_table[S10_SYS_rmdir] = 1; /* 79 */ + s10_emulation_table[S10_SYS_mkdir] = 1; /* 80 */ s10_emulation_table[SYS_getdents] = 1; /* 81 */ s10_emulation_table[S10_SYS_poll] = 1; /* 87 */ s10_emulation_table[S10_SYS_lstat] = 1; /* 88 */ + s10_emulation_table[S10_SYS_symlink] = 1; /* 89 */ + s10_emulation_table[S10_SYS_readlink] = 1; /* 90 */ + s10_emulation_table[S10_SYS_fchmod] = 1; /* 93 */ s10_emulation_table[S10_SYS_fchown] = 1; /* 94 */ s10_emulation_table[SYS_sigprocmask] = 1; /* 95 */ s10_emulation_table[SYS_sigsuspend] = 1; /* 96 */ diff --git a/usr/src/uts/common/brand/solaris10/s10_brand.h b/usr/src/uts/common/brand/solaris10/s10_brand.h index 3686c3600e..0112a783bb 100644 --- a/usr/src/uts/common/brand/solaris10/s10_brand.h +++ b/usr/src/uts/common/brand/solaris10/s10_brand.h @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -106,8 +107,11 @@ enum s10_emulated_features { #define S10_SYS_open 5 #define S10_SYS_wait 7 #define S10_SYS_creat 8 +#define S10_SYS_link 9 #define S10_SYS_unlink 10 #define S10_SYS_exec 11 +#define S10_SYS_mknod 14 +#define S10_SYS_chmod 15 #define S10_SYS_chown 16 #define S10_SYS_stat 18 #define S10_SYS_umount 22 @@ -118,8 +122,12 @@ enum s10_emulated_features { #define S10_SYS_issetugid 75 #define S10_SYS_fsat 76 #define S10_SYS_rmdir 79 +#define S10_SYS_mkdir 80 #define S10_SYS_poll 87 #define S10_SYS_lstat 88 +#define S10_SYS_symlink 89 +#define S10_SYS_readlink 90 +#define S10_SYS_fchmod 93 #define S10_SYS_fchown 94 #define S10_SYS_xstat 123 #define S10_SYS_lxstat 124 diff --git a/usr/src/uts/common/c2/audit.c b/usr/src/uts/common/c2/audit.c index aa3fd4e1b9..bbaf783668 100644 --- a/usr/src/uts/common/c2/audit.c +++ b/usr/src/uts/common/c2/audit.c @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -1026,20 +1027,26 @@ audit_setfsat_path(int argnum) switch (tad->tad_scid) { case SYS_faccessat: + case SYS_fchmodat: case SYS_fchownat: case SYS_fstatat: case SYS_fstatat64: + case SYS_mkdirat: + case SYS_mknodat: case SYS_openat: case SYS_openat64: + case SYS_readlinkat: case SYS_unlinkat: fd = uap->arg1; break; + case SYS_linkat: case SYS_renameat: if (argnum == 3) fd = uap->arg3; else fd = uap->arg1; break; + case SYS_symlinkat: case SYS_utimesys: fd = uap->arg2; break; diff --git a/usr/src/uts/common/c2/audit_event.c b/usr/src/uts/common/c2/audit_event.c index 270fa59c96..69464b2b32 100644 --- a/usr/src/uts/common/c2/audit_event.c +++ b/usr/src/uts/common/c2/audit_event.c @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -80,6 +81,7 @@ char _depends_on[] = "fs/sockfs"; static au_event_t aui_fchownat(au_event_t); +static au_event_t aui_fchmodat(au_event_t); static au_event_t aui_open(au_event_t); static au_event_t aui_openat(au_event_t); static au_event_t aui_unlinkat(au_event_t); @@ -114,9 +116,12 @@ static void aus_fchownat(struct t_audit_data *); static void aus_chmod(struct t_audit_data *); static void aus_facl(struct t_audit_data *); static void aus_fchmod(struct t_audit_data *); +static void aus_fchmodat(struct t_audit_data *); static void aus_fcntl(struct t_audit_data *); static void aus_mkdir(struct t_audit_data *); +static void aus_mkdirat(struct t_audit_data *); static void aus_mknod(struct t_audit_data *); +static void aus_mknodat(struct t_audit_data *); static void aus_mount(struct t_audit_data *); static void aus_umount2(struct t_audit_data *); static void aus_msgsys(struct t_audit_data *); @@ -149,6 +154,7 @@ static void aus_setreuid(struct t_audit_data *); static void aus_labelsys(struct t_audit_data *); static void auf_mknod(struct t_audit_data *, int, rval_t *); +static void auf_mknodat(struct t_audit_data *, int, rval_t *); static void auf_msgsys(struct t_audit_data *, int, rval_t *); static void auf_semsys(struct t_audit_data *, int, rval_t *); static void auf_shmsys(struct t_audit_data *, int, rval_t *); @@ -210,7 +216,7 @@ aui_open, AUE_OPEN, aus_open, /* 5 open */ auf_null, S2E_SP, aui_null, AUE_CLOSE, aus_close, /* 6 close */ auf_null, 0, -aui_null, AUE_NULL, aus_null, /* 7 (loadable) was wait */ +aui_null, AUE_LINK, aus_null, /* 7 linkat */ auf_null, 0, aui_null, AUE_NULL, aus_null, /* 8 (loadable) was creat */ auf_null, 0, @@ -218,14 +224,14 @@ aui_null, AUE_LINK, aus_null, /* 9 link */ auf_null, 0, aui_null, AUE_UNLINK, aus_null, /* 10 unlink */ auf_null, 0, -aui_null, AUE_NULL, aus_null, /* 11 (loadable) was exec */ +aui_null, AUE_SYMLINK, aus_null, /* 11 symlinkat */ auf_null, 0, aui_null, AUE_CHDIR, aus_null, /* 12 chdir */ auf_null, S2E_SP, aui_null, AUE_NULL, aus_null, /* 13 time */ auf_null, 0, aui_null, AUE_MKNOD, aus_mknod, /* 14 mknod */ - auf_mknod, 0, + auf_mknod, S2E_MLD, aui_null, AUE_CHMOD, aus_chmod, /* 15 chmod */ auf_null, 0, aui_null, AUE_CHOWN, aus_chown, /* 16 chown */ @@ -240,8 +246,8 @@ aui_null, AUE_NULL, aus_null, /* 20 getpid */ auf_null, 0, aui_null, AUE_MOUNT, aus_mount, /* 21 mount */ auf_null, S2E_MLD, -aui_null, AUE_NULL, aus_null, /* 22 (loadable) was umount */ - auf_null, 0, +aui_null, AUE_READLINK, aus_null, /* 22 readlinkat */ + auf_null, S2E_PUB, aui_null, AUE_SETUID, aus_setuid, /* 23 setuid */ auf_null, 0, aui_null, AUE_NULL, aus_null, /* 24 getuid */ @@ -292,8 +298,8 @@ aui_null, AUE_SETGID, aus_setgid, /* 46 setgid */ auf_null, 0, aui_null, AUE_NULL, aus_null, /* 47 getgid */ auf_null, 0, -aui_null, AUE_NULL, aus_null, /* 48 (loadable) was ssig */ - auf_null, 0, +aui_null, AUE_MKNOD, aus_mknodat, /* 48 mknodat */ + auf_mknodat, S2E_MLD, aui_msgsys, AUE_MSGSYS, aus_msgsys, /* 49 (loadable) msgsys */ auf_msgsys, 0, #if defined(__x86) @@ -403,9 +409,9 @@ aui_null, AUE_NULL, aus_null, /* 99 sigpending */ auf_null, 0, aui_null, AUE_NULL, aus_null, /* 100 setcontext */ auf_null, 0, -aui_null, AUE_NULL, aus_null, /* 101 (loadable) */ +aui_fchmodat, AUE_NULL, aus_fchmodat, /* 101 fchmodat */ auf_null, 0, -aui_null, AUE_NULL, aus_null, /* 102 (loadable) */ +aui_null, AUE_MKDIR, aus_mkdirat, /* 102 mkdirat */ auf_null, 0, aui_null, AUE_STATVFS, aus_null, /* 103 statvfs */ auf_null, S2E_PUB, @@ -890,7 +896,6 @@ aus_fchownat(struct t_audit_data *tad) au_uwrite(au_to_arg32(4, "new file gid", gid)); } -/* chmod start function */ /*ARGSUSED*/ static void aus_chmod(struct t_audit_data *tad) @@ -908,7 +913,6 @@ aus_chmod(struct t_audit_data *tad) au_uwrite(au_to_arg32(2, "new file mode", fmode&07777)); } -/* chmod start function */ /*ARGSUSED*/ static void aus_fchmod(struct t_audit_data *tad) @@ -929,14 +933,82 @@ aus_fchmod(struct t_audit_data *tad) au_uwrite(au_to_arg32(2, "new file mode", fmode&07777)); - /* - * convert file pointer to file descriptor - * Note: fd ref count incremented here. - */ + /* + * convert file pointer to file descriptor + * Note: fd ref count incremented here. + */ if ((fp = getf(fd)) == NULL) return; - /* get path from file struct here */ + /* get path from file struct here */ + fad = F2A(fp); + if (fad->fad_aupath != NULL) { + au_uwrite(au_to_path(fad->fad_aupath)); + } else { + au_uwrite(au_to_arg32(1, "no path: fd", fd)); + } + + vp = fp->f_vnode; + audit_attributes(vp); + + /* decrement file descriptor reference count */ + releasef(fd); +} + +static au_event_t +aui_fchmodat(au_event_t e) +{ + klwp_t *clwp = ttolwp(curthread); + + struct a { + long fd; + long fname; /* char * */ + long fmode; + long flag; + } *uap = (struct a *)clwp->lwp_ap; + + if (uap->fname == NULL) + e = AUE_FCHMOD; + else + e = AUE_CHMOD; + + return (e); +} + +/*ARGSUSED*/ +static void +aus_fchmodat(struct t_audit_data *tad) +{ + klwp_t *clwp = ttolwp(curthread); + uint32_t fmode; + uint32_t fd; + struct file *fp; + struct vnode *vp; + struct f_audit_data *fad; + + struct a { + long fd; + long fname; /* char * */ + long fmode; + long flag; + } *uap = (struct a *)clwp->lwp_ap; + + fd = (uint32_t)uap->fd; + fmode = (uint32_t)uap->fmode; + + au_uwrite(au_to_arg32(2, "new file mode", fmode&07777)); + + if (fd == AT_FDCWD || uap->fname != NULL) /* same as chmod() */ + return; + + /* + * convert file pointer to file descriptor + * Note: fd ref count incremented here. + */ + if ((fp = getf(fd)) == NULL) + return; + + /* get path from file struct here */ fad = F2A(fp); if (fad->fad_aupath != NULL) { au_uwrite(au_to_path(fad->fad_aupath)); @@ -959,7 +1031,7 @@ open_event(uint_t fm) { au_event_t e; - switch (fm & (O_RDONLY|O_WRONLY|O_RDWR|O_CREAT|O_TRUNC)) { + switch (fm & (O_ACCMODE | O_CREAT | O_TRUNC)) { case O_RDONLY: e = AUE_OPEN_R; break; @@ -996,6 +1068,12 @@ open_event(uint_t fm) case O_RDWR | O_TRUNC | O_CREAT: e = AUE_OPEN_RWTC; break; + case O_SEARCH: + e = AUE_OPEN_S; + break; + case O_EXEC: + e = AUE_OPEN_E; + break; default: e = AUE_NULL; break; @@ -1502,6 +1580,24 @@ aus_mkdir(struct t_audit_data *tad) /*ARGSUSED*/ static void +aus_mkdirat(struct t_audit_data *tad) +{ + klwp_t *clwp = ttolwp(curthread); + uint32_t dmode; + + struct a { + long fd; + long dirnamep; /* char * */ + long dmode; + } *uap = (struct a *)clwp->lwp_ap; + + dmode = (uint32_t)uap->dmode; + + au_uwrite(au_to_arg32(2, "mode", dmode)); +} + +/*ARGSUSED*/ +static void aus_mknod(struct t_audit_data *tad) { klwp_t *clwp = ttolwp(curthread); @@ -1540,19 +1636,77 @@ auf_mknod(struct t_audit_data *tad, int error, rval_t *rval) } *uap = (struct a *)clwp->lwp_ap; /* no error, then already path token in audit record */ - if (error != EPERM) + if (error != EPERM && error != EINVAL) return; - /* not auditing this event, nothing then to do */ - if (tad->tad_flag == 0) + /* do the lookup to force generation of path token */ + pnamep = (caddr_t)uap->pnamep; + tad->tad_ctrl |= TAD_NOATTRB; + error = lookupname(pnamep, UIO_USERSPACE, NO_FOLLOW, &dvp, NULLVPP); + if (error == 0) + VN_RELE(dvp); +} + +/*ARGSUSED*/ +static void +aus_mknodat(struct t_audit_data *tad) +{ + klwp_t *clwp = ttolwp(curthread); + uint32_t fmode; + dev_t dev; + + struct a { + long fd; + long pnamep; /* char * */ + long fmode; + long dev; + } *uap = (struct a *)clwp->lwp_ap; + + fmode = (uint32_t)uap->fmode; + dev = (dev_t)uap->dev; + + au_uwrite(au_to_arg32(2, "mode", fmode)); +#ifdef _LP64 + au_uwrite(au_to_arg64(3, "dev", dev)); +#else + au_uwrite(au_to_arg32(3, "dev", dev)); +#endif +} + +/*ARGSUSED*/ +static void +auf_mknodat(struct t_audit_data *tad, int error, rval_t *rval) +{ + klwp_t *clwp = ttolwp(curthread); + vnode_t *startvp; + vnode_t *dvp; + caddr_t pnamep; + int fd; + + struct a { + long fd; + long pnamep; /* char * */ + long fmode; + long dev; + } *uap = (struct a *)clwp->lwp_ap; + + /* no error, then already path token in audit record */ + if (error != EPERM && error != EINVAL) return; /* do the lookup to force generation of path token */ + fd = (int)uap->fd; pnamep = (caddr_t)uap->pnamep; + if (pnamep == NULL || + fgetstartvp(fd, pnamep, &startvp) != 0) + return; tad->tad_ctrl |= TAD_NOATTRB; - error = lookupname(pnamep, UIO_USERSPACE, NO_FOLLOW, &dvp, NULLVPP); + error = lookupnameat(pnamep, UIO_USERSPACE, NO_FOLLOW, &dvp, NULLVPP, + startvp); if (error == 0) VN_RELE(dvp); + if (startvp != NULL) + VN_RELE(startvp); } /*ARGSUSED*/ diff --git a/usr/src/uts/common/c2/audit_kevents.h b/usr/src/uts/common/c2/audit_kevents.h index b106fdd3d6..758654dfcc 100644 --- a/usr/src/uts/common/c2/audit_kevents.h +++ b/usr/src/uts/common/c2/audit_kevents.h @@ -159,8 +159,10 @@ extern "C" { #define AUE_ASYNC_DAEMON_EXIT 114 /* =no async_daemon(2) exited */ #define AUE_NFSSVC_EXIT 115 /* =no nfssvc(2) exited */ #define AUE_PFEXEC 116 /* =ps,ex,ua,as execve(2) w/ pfexec */ +#define AUE_OPEN_S 117 /* =fr open(2): search */ +#define AUE_OPEN_E 118 /* =fr open(2): exec */ /* - * 117 - 129 are available for future growth (old SunOS_CMW events + * 119 - 129 are available for future growth (old SunOS_CMW events * that had no libbsm or praudit support or references) */ #define AUE_GETAUID 130 /* =aa getauid(2) */ diff --git a/usr/src/uts/common/fs/lookup.c b/usr/src/uts/common/fs/lookup.c index 6d8e657959..6819509d00 100644 --- a/usr/src/uts/common/fs/lookup.c +++ b/usr/src/uts/common/fs/lookup.c @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -63,7 +64,7 @@ int lookupname( char *fnamep, enum uio_seg seg, - enum symfollow followlink, + int followlink, vnode_t **dirvpp, vnode_t **compvpp) { @@ -79,7 +80,7 @@ int lookupnameatcred( char *fnamep, /* user pathname */ enum uio_seg seg, /* addr space that name is in */ - enum symfollow followlink, /* follow sym links */ + int followlink, /* follow sym links */ vnode_t **dirvpp, /* ret for ptr to parent dir vnode */ vnode_t **compvpp, /* ret for ptr to component vnode */ vnode_t *startvp, /* start path search from vp */ @@ -109,7 +110,7 @@ lookupnameatcred( } int -lookupnameat(char *fnamep, enum uio_seg seg, enum symfollow followlink, +lookupnameat(char *fnamep, enum uio_seg seg, int followlink, vnode_t **dirvpp, vnode_t **compvpp, vnode_t *startvp) { return (lookupnameatcred(fnamep, seg, followlink, dirvpp, compvpp, @@ -120,7 +121,7 @@ int lookuppn( struct pathname *pnp, struct pathname *rpnp, - enum symfollow followlink, + int followlink, vnode_t **dirvpp, vnode_t **compvpp) { @@ -135,7 +136,7 @@ int lookuppnatcred( struct pathname *pnp, /* pathname to lookup */ struct pathname *rpnp, /* if non-NULL, return resolved path */ - enum symfollow followlink, /* (don't) follow sym links */ + int followlink, /* (don't) follow sym links */ vnode_t **dirvpp, /* ptr for parent vnode */ vnode_t **compvpp, /* ptr for entry vnode */ vnode_t *startvp, /* start search from this vp */ @@ -178,7 +179,7 @@ lookuppnatcred( int lookuppnat(struct pathname *pnp, struct pathname *rpnp, - enum symfollow followlink, vnode_t **dirvpp, vnode_t **compvpp, + int followlink, vnode_t **dirvpp, vnode_t **compvpp, vnode_t *startvp) { return (lookuppnatcred(pnp, rpnp, followlink, dirvpp, compvpp, startvp, diff --git a/usr/src/uts/common/fs/vnode.c b/usr/src/uts/common/fs/vnode.c index 4c5e1b3da3..382369c7fc 100644 --- a/usr/src/uts/common/fs/vnode.c +++ b/usr/src/uts/common/fs/vnode.c @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -965,7 +966,7 @@ vn_openat( mode |= VREAD; if (filemode & (FWRITE|FTRUNC)) mode |= VWRITE; - if (filemode & FXATTRDIROPEN) + if (filemode & (FSEARCH|FEXEC|FXATTRDIROPEN)) mode |= VEXEC; /* symlink interpretation */ @@ -1075,6 +1076,18 @@ top: */ if (error = VOP_ACCESS(vp, mode, accessflags, CRED(), NULL)) goto out; + /* + * Require FSEARCH to return a directory. + * Require FEXEC to return a regular file. + */ + if ((filemode & FSEARCH) && vp->v_type != VDIR) { + error = ENOTDIR; + goto out; + } + if ((filemode & FEXEC) && vp->v_type != VREG) { + error = ENOEXEC; /* XXX: error code? */ + goto out; + } } /* @@ -1558,6 +1571,13 @@ out: int vn_link(char *from, char *to, enum uio_seg seg) { + return (vn_linkat(NULL, from, NO_FOLLOW, NULL, to, seg)); +} + +int +vn_linkat(vnode_t *fstartvp, char *from, enum symfollow follow, + vnode_t *tstartvp, char *to, enum uio_seg seg) +{ struct vnode *fvp; /* from vnode ptr */ struct vnode *tdvp; /* to directory vnode ptr */ struct pathname pn; @@ -1565,14 +1585,19 @@ vn_link(char *from, char *to, enum uio_seg seg) struct vattr vattr; dev_t fsid; int estale_retry = 0; + uint32_t auditing = AU_AUDITING(); top: fvp = tdvp = NULL; if (error = pn_get(to, seg, &pn)) return (error); - if (error = lookupname(from, seg, NO_FOLLOW, NULLVPP, &fvp)) + if (auditing && fstartvp != NULL) + audit_setfsat_path(1); + if (error = lookupnameat(from, seg, follow, NULLVPP, &fvp, fstartvp)) goto out; - if (error = lookuppn(&pn, NULL, NO_FOLLOW, &tdvp, NULLVPP)) + if (auditing && tstartvp != NULL) + audit_setfsat_path(3); + if (error = lookuppnat(&pn, NULL, NO_FOLLOW, &tdvp, NULLVPP, tstartvp)) goto out; /* * Make sure both source vnode and target directory vnode are @@ -1652,7 +1677,7 @@ top: * use the lib directory for the rename. */ - if (auditing && (fdvp != NULL)) + if (auditing && fdvp != NULL) audit_setfsat_path(1); /* * Lookup to and from directories. @@ -1669,7 +1694,7 @@ top: goto out; } - if (auditing && (tdvp != NULL)) + if (auditing && tdvp != NULL) audit_setfsat_path(3); if (error = lookuppnat(&tpn, NULL, NO_FOLLOW, &tovp, &targvp, tdvp)) { goto out; diff --git a/usr/src/uts/common/os/core.c b/usr/src/uts/common/os/core.c index ece9d8f0eb..9e04f631a9 100644 --- a/usr/src/uts/common/os/core.c +++ b/usr/src/uts/common/os/core.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -436,9 +435,6 @@ do_core(char *fp, int sig, enum core_types core_type, struct core_globals *cg) #if defined(__sparc) (void) flush_user_windows_to_stack(NULL); #endif -#ifdef SUN_SRC_COMPAT - PTOU(curproc)->u_acflag |= ACORE; -#endif if ((eswp = PTOU(curproc)->u_execsw) == NULL || (eswp = findexec_by_magic(eswp->exec_magic)) == NULL) { error = ENOSYS; diff --git a/usr/src/uts/common/os/exit.c b/usr/src/uts/common/os/exit.c index 5b9d682ce1..47dcb0b7f0 100644 --- a/usr/src/uts/common/os/exit.c +++ b/usr/src/uts/common/os/exit.c @@ -500,10 +500,6 @@ proc_exit(int why, int what) */ prbarrier(p); -#ifdef SUN_SRC_COMPAT - if (code == CLD_KILLED) - u.u_acflag |= AXSIG; -#endif sigfillset(&p->p_ignore); sigemptyset(&p->p_siginfo); sigemptyset(&p->p_sig); diff --git a/usr/src/uts/common/os/fio.c b/usr/src/uts/common/os/fio.c index 4ba4ec7560..a014d25c0f 100644 --- a/usr/src/uts/common/os/fio.c +++ b/usr/src/uts/common/os/fio.c @@ -75,7 +75,6 @@ static uint32_t afd_wait; /* count of waits on non-zero ref count */ #endif /* DEBUG */ kmem_cache_t *file_cache; -static int vpsetattr(vnode_t *, vattr_t *, int); static void port_close_fd(portfd_t *); @@ -1087,6 +1086,7 @@ falloc(vnode_t *vp, int flag, file_t **fpp, int *fdp) mutex_enter(&fp->f_tlock); fp->f_count = 1; fp->f_flag = (ushort_t)flag; + fp->f_flag2 = (flag & (FSEARCH|FEXEC)) >> 16; fp->f_vnode = vp; fp->f_offset = 0; fp->f_audit_data = 0; @@ -1195,7 +1195,7 @@ f_getfl(int fd, int *flagp) error = EBADF; else { vnode_t *vp = fp->f_vnode; - int flag = fp->f_flag; + int flag = fp->f_flag | (fp->f_flag2 << 16); /* * BSD fcntl() FASYNC compatibility. @@ -1460,85 +1460,107 @@ close_exec(uf_info_t *fip) } /* - * Common routine for modifying attributes of named files. + * Utility function called by most of the *at() system call interfaces. + * + * Generate a starting vnode pointer for an (fd, path) pair where 'fd' + * is an open file descriptor for a directory to be used as the starting + * point for the lookup of the relative pathname 'path' (or, if path is + * NULL, generate a vnode pointer for the direct target of the operation). + * + * If we successfully return a non-NULL startvp, it has been the target + * of VN_HOLD() and the caller must call VN_RELE() on it. */ int -namesetattr(char *fnamep, enum symfollow followlink, vattr_t *vap, int flags) +fgetstartvp(int fd, char *path, vnode_t **startvpp) { - vnode_t *vp; - int error = 0; + vnode_t *startvp; + file_t *startfp; + char startchar; - if (error = lookupname(fnamep, UIO_USERSPACE, followlink, NULLVPP, &vp)) - return (set_errno(error)); - if (error = vpsetattr(vp, vap, flags)) - (void) set_errno(error); - VN_RELE(vp); - return (error); -} + if (fd == AT_FDCWD && path == NULL) + return (EFAULT); -/* - * Common routine for modifying attributes of files referenced - * by descriptor. - */ -int -fdsetattr(int fd, vattr_t *vap) -{ - file_t *fp; - vnode_t *vp; - int error = 0; + if (fd == AT_FDCWD) { + /* + * Start from the current working directory. + */ + startvp = NULL; + } else { + if (path == NULL) + startchar = '\0'; + else if (copyin(path, &startchar, sizeof (char))) + return (EFAULT); - if ((fp = getf(fd)) != NULL) { - vp = fp->f_vnode; - if (error = vpsetattr(vp, vap, 0)) { - (void) set_errno(error); + if (startchar == '/') { + /* + * 'path' is an absolute pathname. + */ + startvp = NULL; + } else { + /* + * 'path' is a relative pathname or we will + * be applying the operation to 'fd' itself. + */ + if ((startfp = getf(fd)) == NULL) + return (EBADF); + startvp = startfp->f_vnode; + VN_HOLD(startvp); + releasef(fd); } - releasef(fd); - } else - error = set_errno(EBADF); - return (error); + } + *startvpp = startvp; + return (0); } /* - * Common routine to set the attributes for the given vnode. - * If the vnode is a file and the filesize is being manipulated, - * this makes sure that there are no conflicting non-blocking - * mandatory locks in that region. + * Called from fchownat() and fchmodat() to set ownership and mode. + * The contents of *vap must be set before calling here. */ -static int -vpsetattr(vnode_t *vp, vattr_t *vap, int flags) +int +fsetattrat(int fd, char *path, int flags, struct vattr *vap) { - int error = 0; - int in_crit = 0; - u_offset_t begin; - vattr_t vattr; - ssize_t length; + vnode_t *startvp; + vnode_t *vp; + int error; + + /* + * Since we are never called to set the size of a file, we don't + * need to check for non-blocking locks (via nbl_need_check(vp)). + */ + ASSERT(!(vap->va_mask & AT_SIZE)); + + if ((error = fgetstartvp(fd, path, &startvp)) != 0) + return (error); + if (AU_AUDITING() && startvp != NULL) + audit_setfsat_path(1); + + /* + * Do lookup for fchownat/fchmodat when path not NULL + */ + if (path != NULL) { + if (error = lookupnameat(path, UIO_USERSPACE, + (flags == AT_SYMLINK_NOFOLLOW) ? + NO_FOLLOW : FOLLOW, + NULLVPP, &vp, startvp)) { + if (startvp != NULL) + VN_RELE(startvp); + return (error); + } + } else { + vp = startvp; + ASSERT(vp); + VN_HOLD(vp); + } if (vn_is_readonly(vp)) { error = EROFS; + } else { + error = VOP_SETATTR(vp, vap, 0, CRED(), NULL); } - if (!error && (vap->va_mask & AT_SIZE) && - nbl_need_check(vp)) { - nbl_start_crit(vp, RW_READER); - in_crit = 1; - vattr.va_mask = AT_SIZE; - if (!(error = VOP_GETATTR(vp, &vattr, 0, CRED(), NULL))) { - begin = vap->va_size > vattr.va_size ? - vattr.va_size : vap->va_size; - length = vattr.va_size > vap->va_size ? - vattr.va_size - vap->va_size : - vap->va_size - vattr.va_size; - - if (nbl_conflict(vp, NBL_WRITE, begin, length, 0, - NULL)) { - error = EACCES; - } - } - } - if (!error) - error = VOP_SETATTR(vp, vap, flags, CRED(), NULL); - if (in_crit) - nbl_end_crit(vp); + if (startvp != NULL) + VN_RELE(startvp); + VN_RELE(vp); return (error); } diff --git a/usr/src/uts/common/os/sysent.c b/usr/src/uts/common/os/sysent.c index b956756758..7a40be6d9e 100644 --- a/usr/src/uts/common/os/sysent.c +++ b/usr/src/uts/common/os/sysent.c @@ -20,6 +20,7 @@ */ /* ONC_PLUS EXTRACT START */ + /* * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -58,6 +59,7 @@ int cladm(); int close(); int exece(); int faccessat(); +int fchmodat(); int fchownat(); int fcntl(); int64_t vfork(); @@ -80,11 +82,13 @@ int ioctl(); int kill(); int labelsys(); int link(); +int linkat(); off32_t lseek32(); off_t lseek64(); int lgrpsys(); int mmapobjsys(); int mknod(); +int mknodat(); int mount(); int nice(); int nullsys(); @@ -139,6 +143,7 @@ ssize_t writev(); int syslwp_park(); int rmdir(); int mkdir(); +int mkdirat(); int getdents32(); int statfs32(); int fstatfs32(); @@ -149,7 +154,9 @@ int putmsg(); int uadmin(); int lstat(); int symlink(); +int symlinkat(); ssize_t readlink(); +ssize_t readlinkat(); int resolvepath(); int setgroups(); int getgroups(); @@ -423,11 +430,11 @@ struct sysent sysent[NSYSCALL] = /* 4 */ SYSENT_CL("write", write, 3), /* 5 */ SYSENT_CI("open", open, 3), /* 6 */ SYSENT_CI("close", close, 1), - /* 7 */ SYSENT_LOADABLE(), /* (was wait) */ + /* 7 */ SYSENT_CI("linkat", linkat, 5), /* 8 */ SYSENT_LOADABLE(), /* (was creat) */ /* 9 */ SYSENT_CI("link", link, 2), /* 10 */ SYSENT_CI("unlink", unlink, 1), - /* 11 */ SYSENT_LOADABLE(), /* (was exec) */ + /* 11 */ SYSENT_CI("symlinkat", symlinkat, 3), /* 12 */ SYSENT_CI("chdir", chdir, 1), /* 13 */ SYSENT_CL("time", gtime, 0), /* 14 */ SYSENT_CI("mknod", mknod, 3), @@ -440,7 +447,7 @@ struct sysent sysent[NSYSCALL] = SYSENT_CL("lseek", lseek32, 3)), /* 20 */ SYSENT_2CI("getpid", getpid, 0), /* 21 */ SYSENT_AP("mount", mount, 8), - /* 22 */ SYSENT_LOADABLE(), /* (was umount) */ + /* 22 */ SYSENT_CL("readlinkat", readlinkat, 4), /* 23 */ SYSENT_CI("setuid", setuid, 1), /* 24 */ SYSENT_2CI("getuid", getuid, 0), /* 25 */ SYSENT_CI("stime", stime, 1), @@ -470,7 +477,7 @@ struct sysent sysent[NSYSCALL] = /* 45 */ SYSENT_CI("faccessat", faccessat, 4), /* 46 */ SYSENT_CI("setgid", setgid, 1), /* 47 */ SYSENT_2CI("getgid", getgid, 0), - /* 48 */ SYSENT_LOADABLE(), /* (was ssig) */ + /* 48 */ SYSENT_CI("mknodat", mknodat, 4), /* 49 */ SYSENT_LOADABLE(), /* msgsys */ /* 50 */ IF_x86( SYSENT_CI("sysi86", sysi86, 4), @@ -533,8 +540,8 @@ struct sysent sysent[NSYSCALL] = /* 98 */ SYSENT_CI("sigaction", sigaction, 3), /* 99 */ SYSENT_CI("sigpending", sigpending, 2), /* 100 */ SYSENT_CI("getsetcontext", getsetcontext, 2), - /* 101 */ SYSENT_LOADABLE(), - /* 102 */ SYSENT_LOADABLE(), + /* 101 */ SYSENT_CI("fchmodat", fchmodat, 4), + /* 102 */ SYSENT_CI("mkdirat", mkdirat, 3), /* 103 */ SYSENT_CI("statvfs", statvfs, 2), /* 104 */ SYSENT_CI("fstatvfs", fstatvfs, 2), /* 105 */ SYSENT_CI("getloadavg", getloadavg, 2), @@ -754,6 +761,7 @@ extern ssize_t pwrite32(); extern ssize_t readv32(); extern ssize_t writev32(); extern ssize_t readlink32(); +extern ssize_t readlinkat32(); extern int open32(); extern int openat32(); extern int stat32(); @@ -805,11 +813,11 @@ struct sysent sysent32[NSYSCALL] = /* 4 */ SYSENT_CI("write", write32, 3), /* 5 */ SYSENT_CI("open", open32, 3), /* 6 */ SYSENT_CI("close", close, 1), - /* 7 */ SYSENT_LOADABLE32(), /* (was wait) */ + /* 7 */ SYSENT_CI("linkat", linkat, 5), /* 8 */ SYSENT_LOADABLE32(), /* (was creat32) */ /* 9 */ SYSENT_CI("link", link, 2), /* 10 */ SYSENT_CI("unlink", unlink, 1), - /* 11 */ SYSENT_LOADABLE32(), /* (was exec) */ + /* 11 */ SYSENT_CI("symlinkat", symlinkat, 3), /* 12 */ SYSENT_CI("chdir", chdir, 1), /* 13 */ SYSENT_CI("time", gtime, 0), /* 14 */ SYSENT_CI("mknod", mknod, 3), @@ -820,7 +828,7 @@ struct sysent sysent32[NSYSCALL] = /* 19 */ SYSENT_CI("lseek", lseek32, 3), /* 20 */ SYSENT_2CI("getpid", getpid, 0), /* 21 */ SYSENT_AP("mount", mount, 8), - /* 22 */ SYSENT_LOADABLE32(), /* (was umount) */ + /* 22 */ SYSENT_CI("readlinkat", readlinkat32, 4), /* 23 */ SYSENT_CI("setuid", setuid, 1), /* 24 */ SYSENT_2CI("getuid", getuid, 0), /* 25 */ SYSENT_CI("stime", stime32, 1), @@ -846,7 +854,7 @@ struct sysent sysent32[NSYSCALL] = /* 45 */ SYSENT_CI("faccessat", faccessat, 4), /* 46 */ SYSENT_CI("setgid", setgid, 1), /* 47 */ SYSENT_2CI("getgid", getgid, 0), - /* 48 */ SYSENT_LOADABLE32(), /* (was ssig) */ + /* 48 */ SYSENT_CI("mknodat", mknodat, 4), /* 49 */ SYSENT_LOADABLE32(), /* msgsys */ /* 50 */ IF_386_ABI( SYSENT_CI("sysi86", sysi86, 4), @@ -901,8 +909,8 @@ struct sysent sysent32[NSYSCALL] = /* 98 */ SYSENT_CI("sigaction", sigaction32, 3), /* 99 */ SYSENT_CI("sigpending", sigpending, 2), /* 100 */ SYSENT_CI("getsetcontext", getsetcontext32, 2), - /* 101 */ SYSENT_LOADABLE32(), - /* 102 */ SYSENT_LOADABLE32(), + /* 101 */ SYSENT_CI("fchmodat", fchmodat, 4), + /* 102 */ SYSENT_CI("mkdirat", mkdirat, 3), /* 103 */ SYSENT_CI("statvfs", statvfs32, 2), /* 104 */ SYSENT_CI("fstatvfs", fstatvfs32, 2), /* 105 */ SYSENT_CI("getloadavg", getloadavg, 2), diff --git a/usr/src/uts/common/sys/acct.h b/usr/src/uts/common/sys/acct.h index 7853af96f0..e8903bd0da 100644 --- a/usr/src/uts/common/sys/acct.h +++ b/usr/src/uts/common/sys/acct.h @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,20 +18,17 @@ * * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + #ifndef _SYS_ACCT_H #define _SYS_ACCT_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> #include <sys/types32.h> @@ -104,11 +100,6 @@ int acct_fs_in_use(struct vnode *); #define AFORK 0001 /* has executed fork, but no exec */ #define ASU 0002 /* used super-user privileges */ -#ifdef SUN_SRC_COMPAT -#define ACOMPAT 0004 /* used compatibility mode (VAX) */ -#define ACORE 0010 /* dumped core */ -#define AXSIG 0020 /* killed by a signal */ -#endif /* SUN_SRC_COMPAT */ #define AEXPND 0040 /* expanded acct structure */ #define ACCTF 0300 /* record type: 00 = acct */ diff --git a/usr/src/uts/common/sys/fcntl.h b/usr/src/uts/common/sys/fcntl.h index 9057a671a6..a0c4191b1c 100644 --- a/usr/src/uts/common/sys/fcntl.h +++ b/usr/src/uts/common/sys/fcntl.h @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -50,11 +49,13 @@ extern "C" { /* * Flag values accessible to open(2) and fcntl(2) - * (the first three can only be set by open(2)). + * The first five can only be set (exclusively) by open(2). */ #define O_RDONLY 0 #define O_WRONLY 1 #define O_RDWR 2 +#define O_SEARCH 0x200000 +#define O_EXEC 0x400000 #if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) #define O_NDELAY 0x04 /* non-blocking I/O */ #endif /* defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) */ @@ -67,9 +68,6 @@ extern "C" { /* defines read/write file integrity */ #endif /* defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) ... */ #define O_NONBLOCK 0x80 /* non-blocking I/O (POSIX) */ -#ifdef SUN_SRC_COMPAT -#define O_PRIV 0x1000 /* Private access to file */ -#endif /* SUN_SRC_COMPAT */ #ifdef _LARGEFILE_SOURCE #define O_LARGEFILE 0x2000 #endif @@ -300,7 +298,8 @@ typedef struct o_flock { * POSIX constants */ -#define O_ACCMODE 3 /* Mask for file access modes */ +/* Mask for file access modes */ +#define O_ACCMODE (O_SEARCH | O_EXEC | 0x3) #define FD_CLOEXEC 1 /* close on exec flag */ /* @@ -345,8 +344,10 @@ typedef struct fshare { */ #if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \ defined(__EXTENSIONS__) + /* || defined(_XPG7) */ #define AT_FDCWD 0xffd19553 #define AT_SYMLINK_NOFOLLOW 0x1000 +#define AT_SYMLINK_FOLLOW 0x2000 /* only for linkat() */ #define AT_REMOVEDIR 0x1 #define _AT_TRIGGER 0x2 #define AT_EACCESS 0x4 /* use EUID/EGID for access */ diff --git a/usr/src/uts/common/sys/file.h b/usr/src/uts/common/sys/file.h index 494840aff8..f402bc7079 100644 --- a/usr/src/uts/common/sys/file.h +++ b/usr/src/uts/common/sys/file.h @@ -18,20 +18,17 @@ * * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + #ifndef _SYS_FILE_H #define _SYS_FILE_H -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 11.28 */ - #include <sys/t_lock.h> #ifdef _KERNEL #include <sys/model.h> @@ -61,7 +58,7 @@ extern "C" { typedef struct file { kmutex_t f_tlock; /* short term lock */ ushort_t f_flag; - ushort_t f_pad; /* Explicit pad to 4 byte boundary */ + ushort_t f_flag2; /* extra flags (FSEARCH, FEXEC) */ struct vnode *f_vnode; /* pointer to vnode structure */ offset_t f_offset; /* read/write character pointer */ struct cred *f_cred; /* credentials of user who opened it */ @@ -77,7 +74,7 @@ typedef struct fpollinfo { struct fpollinfo *fp_next; } fpollinfo_t; -/* flags */ +/* f_flag */ #define FOPEN 0xffffffff #define FREAD 0x01 /* <sys/aiocb.h> LIO_READ must be identical */ @@ -111,6 +108,11 @@ typedef struct fpollinfo { #define FIGNORECASE 0x80000 /* request case-insensitive lookups */ #define FXATTRDIROPEN 0x100000 /* only opening hidden attribute directory */ +/* f_flag2 (open-only) */ + +#define FSEARCH 0x200000 /* O_SEARCH = 0x200000 */ +#define FEXEC 0x400000 /* O_EXEC = 0x400000 */ + #ifdef _KERNEL /* @@ -170,6 +172,7 @@ typedef struct fpollinfo { */ struct proc; /* forward reference for function prototype */ struct vnodeops; +struct vattr; extern file_t *getf(int); extern void releasef(int); @@ -199,6 +202,8 @@ extern void close_exec(uf_info_t *); extern void clear_stale_fd(void); extern void clear_active_fd(int); extern void free_afd(afd_t *afd); +extern int fgetstartvp(int, char *, struct vnode **); +extern int fsetattrat(int, char *, int, struct vattr *); extern int fisopen(struct vnode *); extern void delfpollinfo(int); extern void addfpollinfo(int); diff --git a/usr/src/uts/common/sys/pathname.h b/usr/src/uts/common/sys/pathname.h index 305e3cf09c..db978c1ea9 100644 --- a/usr/src/uts/common/sys/pathname.h +++ b/usr/src/uts/common/sys/pathname.h @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -80,17 +80,17 @@ extern int pn_fixslash(struct pathname *); extern int pn_addslash(struct pathname *); extern void pn_free(struct pathname *); -extern int lookupname(char *, enum uio_seg, enum symfollow, +extern int lookupname(char *, enum uio_seg, int follow, vnode_t **, vnode_t **); -extern int lookupnameat(char *, enum uio_seg, enum symfollow, +extern int lookupnameat(char *, enum uio_seg, int follow, vnode_t **, vnode_t **, vnode_t *); -extern int lookupnameatcred(char *, enum uio_seg, enum symfollow, +extern int lookupnameatcred(char *, enum uio_seg, int follow, vnode_t **, vnode_t **, vnode_t *, cred_t *); -extern int lookuppn(struct pathname *, struct pathname *, enum symfollow, +extern int lookuppn(struct pathname *, struct pathname *, int follow, vnode_t **, vnode_t **); -extern int lookuppnat(struct pathname *, struct pathname *, enum symfollow, +extern int lookuppnat(struct pathname *, struct pathname *, int follow, vnode_t **, vnode_t **, vnode_t *); -extern int lookuppnatcred(struct pathname *, struct pathname *, enum symfollow, +extern int lookuppnatcred(struct pathname *, struct pathname *, int follow, vnode_t **, vnode_t **, vnode_t *, cred_t *); extern int lookuppnvp(struct pathname *, struct pathname *, int follow, diff --git a/usr/src/uts/common/sys/stat.h b/usr/src/uts/common/sys/stat.h index 81fb9e4ab8..3f68a55730 100644 --- a/usr/src/uts/common/sys/stat.h +++ b/usr/src/uts/common/sys/stat.h @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ @@ -505,9 +504,13 @@ extern int fstatat64(int, const char *, struct stat64 *, int); #endif /* defined (_ATFILE_SOURCE) */ #endif -#if defined(__EXTENSIONS__) || \ +#if defined(__EXTENSIONS__) || defined(_ATFILE_SOURCE) || \ (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) /* || defined(_XPG7) */ +extern int mkdirat(int, const char *, mode_t); +extern int mkfifoat(int, const char *, mode_t); +extern int mknodat(int, const char *, mode_t, dev_t); +extern int fchmodat(int, const char *, mode_t, int); extern int futimens(int, const struct timespec[2]); extern int utimensat(int, const char *, const struct timespec[2], int); #endif /* defined(__EXTENSIONS__) ... */ @@ -536,9 +539,13 @@ extern int fstatat64(); #endif /* defined (_ATFILE_SOURCE) */ #endif -#if defined(__EXTENSIONS__) || \ +#if defined(__EXTENSIONS__) || defined(_ATFILE_SOURCE) || \ (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) /* || defined(_XPG7) */ +extern int mkdirat(); +extern int mkfifoat(); +extern int mknodat(); +extern int fchmodat(); extern int futimens(); extern int utimensat(); #endif /* defined(__EXTENSIONS__) ... */ diff --git a/usr/src/uts/common/sys/syscall.h b/usr/src/uts/common/sys/syscall.h index 170483de8d..633bfef143 100644 --- a/usr/src/uts/common/sys/syscall.h +++ b/usr/src/uts/common/sys/syscall.h @@ -20,8 +20,7 @@ */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -53,8 +52,10 @@ extern "C" { #define SYS_write 4 #define SYS_open 5 #define SYS_close 6 +#define SYS_linkat 7 #define SYS_link 9 #define SYS_unlink 10 +#define SYS_symlinkat 11 #define SYS_chdir 12 #define SYS_time 13 #define SYS_mknod 14 @@ -65,6 +66,7 @@ extern "C" { #define SYS_lseek 19 #define SYS_getpid 20 #define SYS_mount 21 +#define SYS_readlinkat 22 #define SYS_setuid 23 #define SYS_getuid 24 #define SYS_stime 25 @@ -97,6 +99,7 @@ extern "C" { #define SYS_faccessat 45 #define SYS_setgid 46 #define SYS_getgid 47 +#define SYS_mknodat 48 #define SYS_msgsys 49 /* * subcodes: @@ -260,6 +263,8 @@ extern "C" { * getcontext(...) :: syscall(100, 0, ...) * setcontext(...) :: syscall(100, 1, ...) */ +#define SYS_fchmodat 101 +#define SYS_mkdirat 102 #define SYS_statvfs 103 #define SYS_fstatvfs 104 #define SYS_getloadavg 105 diff --git a/usr/src/uts/common/sys/vnode.h b/usr/src/uts/common/sys/vnode.h index 1fbcb29005..b34eb6b4ff 100644 --- a/usr/src/uts/common/sys/vnode.h +++ b/usr/src/uts/common/sys/vnode.h @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -1159,7 +1160,7 @@ extern int fop_retzcbuf(vnode_t *, xuio_t *, cred_t *, caller_context_t *); /* * Flags for VOP_LOOKUP * - * Defined in file.h, but also possible, FIGNORECASE + * Defined in file.h, but also possible, FIGNORECASE and FSEARCH * */ #define LOOKUP_DIR 0x01 /* want parent dir vp */ @@ -1244,6 +1245,8 @@ void vn_rele_async(struct vnode *vp, struct taskq *taskq); void vn_rele_dnlc(struct vnode *vp); void vn_rele_stream(struct vnode *vp); int vn_link(char *from, char *to, enum uio_seg seg); +int vn_linkat(vnode_t *fstartvp, char *from, enum symfollow follow, + vnode_t *tstartvp, char *to, enum uio_seg seg); int vn_rename(char *from, char *to, enum uio_seg seg); int vn_renameat(vnode_t *fdvp, char *fname, vnode_t *tdvp, char *tname, enum uio_seg seg); diff --git a/usr/src/uts/common/syscall/access.c b/usr/src/uts/common/syscall/access.c index 9e4f1aac84..a6bda94367 100644 --- a/usr/src/uts/common/syscall/access.c +++ b/usr/src/uts/common/syscall/access.c @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -68,7 +69,7 @@ caccess(char *fname, int fmode, vnode_t *startvp) int estale_retry = 0; if (fmode & ~(E_OK|R_OK|W_OK|X_OK)) - return (set_errno(EINVAL)); + return (EINVAL); mode = ((fmode & (R_OK|W_OK|X_OK)) << 6); @@ -95,7 +96,7 @@ lookup: goto lookup; if (!eok) crfree(tmpcr); - return (set_errno(error)); + return (error); } if (mode) { @@ -106,7 +107,6 @@ lookup: VN_RELE(vp); goto lookup; } - (void) set_errno(error); } } @@ -119,39 +119,17 @@ lookup: int faccessat(int fd, char *fname, int fmode, int flag) { - file_t *dirfp; - vnode_t *dirvp; + vnode_t *startvp; int error; - char startchar; - - if (fd == AT_FDCWD && fname == NULL) - return (set_errno(EFAULT)); if ((flag & ~AT_EACCESS) != 0) return (set_errno(EINVAL)); - if (fname != NULL) { - if (copyin(fname, &startchar, sizeof (char))) - return (set_errno(EFAULT)); - } else - startchar = '\0'; - - if (fd == AT_FDCWD) { - dirvp = NULL; - } else { - if (startchar != '/') { - if ((dirfp = getf(fd)) == NULL) { - return (set_errno(EBADF)); - } - dirvp = dirfp->f_vnode; - VN_HOLD(dirvp); - releasef(fd); - } else { - dirvp = NULL; - } - } - - if (AU_AUDITING() && (dirvp != NULL)) + if (fname == NULL) + return (set_errno(EFAULT)); + if ((error = fgetstartvp(fd, fname, &startvp)) != 0) + return (set_errno(error)); + if (AU_AUDITING() && startvp != NULL) audit_setfsat_path(1); /* Do not allow E_OK unless AT_EACCESS flag is set */ @@ -159,11 +137,12 @@ faccessat(int fd, char *fname, int fmode, int flag) if (flag & AT_EACCESS) fmode |= E_OK; - error = caccess(fname, fmode, dirvp); - if (dirvp != NULL) - VN_RELE(dirvp); - - return (error); + error = caccess(fname, fmode, startvp); + if (startvp != NULL) + VN_RELE(startvp); + if (error) + return (set_errno(error)); + return (0); } int diff --git a/usr/src/uts/common/syscall/chmod.c b/usr/src/uts/common/syscall/chmod.c index 8fb42e0843..bed521f0b3 100644 --- a/usr/src/uts/common/syscall/chmod.c +++ b/usr/src/uts/common/syscall/chmod.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,21 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 1989 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ident "%Z%%M% %I% %E% SMI" - #include <sys/param.h> #include <sys/isa_defs.h> #include <sys/types.h> @@ -51,31 +43,43 @@ #include <sys/filio.h> #include <sys/debug.h> -extern int namesetattr(char *, enum symfollow, vattr_t *, int); -extern int fdsetattr(int, vattr_t *); - /* - * Change mode of file given path name. + * Change mode of file. */ int -chmod(char *fname, int fmode) +fchmodat(int fd, char *path, int mode, int flag) { struct vattr vattr; + int error; + + if (flag & ~AT_SYMLINK_NOFOLLOW) + return (set_errno(EINVAL)); - vattr.va_mode = fmode & MODEMASK; + if (flag & AT_SYMLINK_NOFOLLOW) + return (set_errno(EOPNOTSUPP)); + + vattr.va_mode = mode & MODEMASK; vattr.va_mask = AT_MODE; - return (namesetattr(fname, FOLLOW, &vattr, 0)); + error = fsetattrat(fd, path, flag, &vattr); + if (error) + return (set_errno(error)); + return (0); } /* - * Change mode of file given file descriptor. + * Change mode of file given path name. */ int -fchmod(int fd, int fmode) +chmod(char *path, int mode) { - struct vattr vattr; + return (fchmodat(AT_FDCWD, path, mode, 0)); +} - vattr.va_mode = fmode & MODEMASK; - vattr.va_mask = AT_MODE; - return (fdsetattr(fd, &vattr)); +/* + * Change mode of file given file descriptor. + */ +int +fchmod(int fd, int mode) +{ + return (fchmodat(fd, NULL, mode, 0)); } diff --git a/usr/src/uts/common/syscall/chown.c b/usr/src/uts/common/syscall/chown.c index ccb0b584ee..40c76e61bc 100644 --- a/usr/src/uts/common/syscall/chown.c +++ b/usr/src/uts/common/syscall/chown.c @@ -55,13 +55,10 @@ * Change ownership of file. */ int -fchownat(int fd, char *name, uid_t uid, gid_t gid, int flags) +fchownat(int fd, char *path, uid_t uid, gid_t gid, int flag) { - vnode_t *startvp, *vp; - file_t *filefp; struct vattr vattr; - int error = 0; - char startchar; + int error; struct zone *zone = crgetzone(CRED()); if (uid != (uid_t)-1 && !VALID_UID(uid, zone) || @@ -76,83 +73,22 @@ fchownat(int fd, char *name, uid_t uid, gid_t gid, int flags) if (vattr.va_gid != -1) vattr.va_mask |= AT_GID; - - if (fd == AT_FDCWD && name == NULL) - return (set_errno(EFAULT)); - - if (name != NULL) { - if (copyin(name, &startchar, sizeof (char))) - return (set_errno(EFAULT)); - } else { - startchar = '\0'; - } - - - if (fd == AT_FDCWD) - startvp = NULL; - else { - /* - * only get fd if not doing absolute lookup - */ - if (startchar != '/') { - if ((filefp = getf(fd)) == NULL) - return (set_errno(EBADF)); - startvp = filefp->f_vnode; - VN_HOLD(startvp); - releasef(fd); - } else { - startvp = NULL; - } - } - - if (AU_AUDITING() && (startvp != NULL)) - audit_setfsat_path(1); - - /* - * Do lookup for fchownat when name not NULL - */ - if (name != NULL) { - if (error = lookupnameat(name, UIO_USERSPACE, - (flags == AT_SYMLINK_NOFOLLOW) ? - NO_FOLLOW : FOLLOW, - NULLVPP, &vp, startvp)) { - if (startvp != NULL) - VN_RELE(startvp); - return (set_errno(error)); - } - } else { - vp = startvp; - ASSERT(vp); - VN_HOLD(vp); - } - - if (vn_is_readonly(vp)) { - error = EROFS; - } else { - error = VOP_SETATTR(vp, &vattr, 0, CRED(), NULL); - } - - if (startvp != NULL) - VN_RELE(startvp); - if (vp != NULL) - VN_RELE(vp); - - if (error != 0) + error = fsetattrat(fd, path, flag, &vattr); + if (error) return (set_errno(error)); - else - return (error); + return (0); } int -chown(char *fname, uid_t uid, gid_t gid) +chown(char *path, uid_t uid, gid_t gid) { - return (fchownat(AT_FDCWD, fname, uid, gid, 0)); + return (fchownat(AT_FDCWD, path, uid, gid, 0)); } int -lchown(char *fname, uid_t uid, gid_t gid) +lchown(char *path, uid_t uid, gid_t gid) { - return (fchownat(AT_FDCWD, fname, uid, gid, AT_SYMLINK_NOFOLLOW)); + return (fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW)); } int diff --git a/usr/src/uts/common/syscall/fcntl.c b/usr/src/uts/common/syscall/fcntl.c index 0750e54697..4a6e58f6b0 100644 --- a/usr/src/uts/common/syscall/fcntl.c +++ b/usr/src/uts/common/syscall/fcntl.c @@ -114,13 +114,21 @@ fcntl(int fdes, int cmd, intptr_t arg) goto out; case F_GETFL: - if ((error = f_getfl(fdes, &flag)) == 0) - retval = (flag & (FMASK | FASYNC)) + FOPEN; + if ((error = f_getfl(fdes, &flag)) == 0) { + retval = (flag & (FMASK | FASYNC)); + if ((flag & (FSEARCH | FEXEC)) == 0) + retval += FOPEN; + else + retval |= (flag & (FSEARCH | FEXEC)); + } goto out; case F_GETXFL: - if ((error = f_getfl(fdes, &flag)) == 0) - retval = flag + FOPEN; + if ((error = f_getfl(fdes, &flag)) == 0) { + retval = flag; + if ((flag & (FSEARCH | FEXEC)) == 0) + retval += FOPEN; + } goto out; case F_BADFD: diff --git a/usr/src/uts/common/syscall/getdents.c b/usr/src/uts/common/syscall/getdents.c index da91808e74..944c9321aa 100644 --- a/usr/src/uts/common/syscall/getdents.c +++ b/usr/src/uts/common/syscall/getdents.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -93,6 +93,10 @@ getdents32(int fd, void *buf, size_t count) releasef(fd); return (set_errno(ENOTDIR)); } + if (!(fp->f_flag & FREAD)) { + releasef(fd); + return (set_errno(EBADF)); + } /* * Don't let the user overcommit kernel resources. @@ -207,6 +211,10 @@ getdents64(int fd, void *buf, size_t count) releasef(fd); return (set_errno(ENOTDIR)); } + if (!(fp->f_flag & FREAD)) { + releasef(fd); + return (set_errno(EBADF)); + } aiov.iov_base = buf; aiov.iov_len = count; auio.uio_iov = &aiov; diff --git a/usr/src/uts/common/syscall/link.c b/usr/src/uts/common/syscall/link.c index a63b04f133..5e6522ce8d 100644 --- a/usr/src/uts/common/syscall/link.c +++ b/usr/src/uts/common/syscall/link.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 1989 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -32,8 +31,6 @@ * under license from the Regents of the University of California. */ -#ident "%Z%%M% %I% %E% SMI" - #include <sys/param.h> #include <sys/isa_defs.h> #include <sys/types.h> @@ -41,18 +38,48 @@ #include <sys/systm.h> #include <sys/errno.h> #include <sys/vnode.h> +#include <sys/file.h> +#include <sys/fcntl.h> #include <sys/uio.h> #include <sys/debug.h> +#include <c2/audit.h> /* * Make a hard link. */ int -link(char *from, char *to) +linkat(int ffd, char *from, int tfd, char *to, int flag) { - int error; + vnode_t *fstartvp = NULL; + vnode_t *tstartvp = NULL; + enum symfollow follow; + int error; + + if (flag & ~AT_SYMLINK_FOLLOW) + return (set_errno(EINVAL)); + follow = (flag & AT_SYMLINK_FOLLOW)? FOLLOW : NO_FOLLOW; + + if (from == NULL || to == NULL) + return (set_errno(EFAULT)); + if ((error = fgetstartvp(ffd, from, &fstartvp)) != 0) + goto out; + if ((error = fgetstartvp(tfd, to, &tstartvp)) != 0) + goto out; + + error = vn_linkat(fstartvp, from, follow, tstartvp, to, UIO_USERSPACE); - if (error = vn_link(from, to, UIO_USERSPACE)) +out: + if (fstartvp != NULL) + VN_RELE(fstartvp); + if (tstartvp != NULL) + VN_RELE(tstartvp); + if (error) return (set_errno(error)); return (0); } + +int +link(char *from, char *to) +{ + return (linkat(AT_FDCWD, from, AT_FDCWD, to, 0)); +} diff --git a/usr/src/uts/common/syscall/mkdir.c b/usr/src/uts/common/syscall/mkdir.c index ef50e5a99d..ce21aaffc2 100644 --- a/usr/src/uts/common/syscall/mkdir.c +++ b/usr/src/uts/common/syscall/mkdir.c @@ -20,11 +20,9 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. */ - /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ @@ -33,8 +31,6 @@ * under license from the Regents of the University of California. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/param.h> #include <sys/isa_defs.h> #include <sys/types.h> @@ -43,15 +39,19 @@ #include <sys/user.h> #include <sys/errno.h> #include <sys/vnode.h> +#include <sys/file.h> +#include <sys/fcntl.h> #include <sys/uio.h> #include <sys/debug.h> +#include <c2/audit.h> /* * Make a directory. */ int -mkdir(char *dname, int dmode) +mkdirat(int fd, char *dname, int dmode) { + vnode_t *startvp; vnode_t *vp; struct vattr vattr; int error; @@ -59,10 +59,26 @@ mkdir(char *dname, int dmode) vattr.va_type = VDIR; vattr.va_mode = dmode & PERMMASK; vattr.va_mask = AT_TYPE|AT_MODE; - error = vn_create(dname, UIO_USERSPACE, &vattr, EXCL, 0, &vp, CRMKDIR, - 0, PTOU(curproc)->u_cmask); + + if (dname == NULL) + return (set_errno(EFAULT)); + if ((error = fgetstartvp(fd, dname, &startvp)) != 0) + return (set_errno(error)); + if (AU_AUDITING() && startvp != NULL) + audit_setfsat_path(1); + + error = vn_createat(dname, UIO_USERSPACE, &vattr, EXCL, 0, &vp, + CRMKDIR, 0, PTOU(curproc)->u_cmask, startvp); + if (startvp != NULL) + VN_RELE(startvp); if (error) return (set_errno(error)); VN_RELE(vp); return (0); } + +int +mkdir(char *dname, int dmode) +{ + return (mkdirat(AT_FDCWD, dname, dmode)); +} diff --git a/usr/src/uts/common/syscall/mknod.c b/usr/src/uts/common/syscall/mknod.c index 73258f9c2f..82fe837622 100644 --- a/usr/src/uts/common/syscall/mknod.c +++ b/usr/src/uts/common/syscall/mknod.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -41,11 +40,14 @@ #include <sys/errno.h> #include <sys/stat.h> #include <sys/vnode.h> +#include <sys/file.h> +#include <sys/fcntl.h> #include <sys/mode.h> #include <sys/uio.h> #include <sys/mkdev.h> #include <sys/policy.h> #include <sys/debug.h> +#include <c2/audit.h> /* * Create a special file, a regular file, or a FIFO. @@ -54,8 +56,9 @@ * dev = device number - b/c specials only */ int -mknod(char *fname, mode_t fmode, dev_t dev) +mknodat(int fd, char *fname, mode_t fmode, dev_t dev) { + vnode_t *startvp; vnode_t *vp; struct vattr vattr; int error; @@ -86,10 +89,27 @@ mknod(char *fname, mode_t fmode, dev_t dev) vattr.va_rdev = dev; vattr.va_mask |= AT_RDEV; } + + if (fname == NULL) + return (set_errno(EFAULT)); + if ((error = fgetstartvp(fd, fname, &startvp)) != 0) + return (set_errno(error)); + if (AU_AUDITING() && startvp != NULL) + audit_setfsat_path(1); + why = ((fmode & S_IFMT) == S_IFDIR) ? CRMKDIR : CRMKNOD; - if (error = vn_create(fname, UIO_USERSPACE, &vattr, EXCL, 0, &vp, - why, 0, PTOU(curproc)->u_cmask)) + error = vn_createat(fname, UIO_USERSPACE, &vattr, EXCL, 0, &vp, + why, 0, PTOU(curproc)->u_cmask, startvp); + if (startvp != NULL) + VN_RELE(startvp); + if (error) return (set_errno(error)); VN_RELE(vp); return (0); } + +int +mknod(char *fname, mode_t fmode, dev_t dev) +{ + return (mknodat(AT_FDCWD, fname, fmode, dev)); +} diff --git a/usr/src/uts/common/syscall/open.c b/usr/src/uts/common/syscall/open.c index 154c1a6953..6559900158 100644 --- a/usr/src/uts/common/syscall/open.c +++ b/usr/src/uts/common/syscall/open.c @@ -69,6 +69,18 @@ copen(int startfd, char *fname, int filemode, int createmode) uint32_t auditing = AU_AUDITING(); char startchar; + if (filemode & (FSEARCH|FEXEC)) { + /* + * Must be one or the other and neither FREAD nor FWRITE + * Must not be any of FAPPEND FCREAT FTRUNC FXATTR FXATTRDIROPEN + * XXX: Should these just be silently ignored? + */ + if ((filemode & (FREAD|FWRITE)) || + (filemode & (FSEARCH|FEXEC)) == (FSEARCH|FEXEC) || + (filemode & (FAPPEND|FCREAT|FTRUNC|FXATTR|FXATTRDIROPEN))) + return (set_errno(EINVAL)); + } + if (startfd == AT_FDCWD) { /* * Regular open() @@ -99,9 +111,8 @@ copen(int startfd, char *fname, int filemode, int createmode) * Handle __openattrdirat() requests */ if (filemode & FXATTRDIROPEN) { - if (auditing && (startvp != NULL)) + if (auditing && startvp != NULL) audit_setfsat_path(1); - if (error = lookupnameat(fname, seg, FOLLOW, NULLVPP, &vp, startvp)) return (set_errno(error)); @@ -188,12 +199,12 @@ copen(int startfd, char *fname, int filemode, int createmode) } noxattr: - if ((filemode & (FREAD|FWRITE|FXATTRDIROPEN)) != 0) { + if ((filemode & (FREAD|FWRITE|FSEARCH|FEXEC|FXATTRDIROPEN)) != 0) { if ((filemode & (FNONBLOCK|FNDELAY)) == (FNONBLOCK|FNDELAY)) filemode &= ~FNDELAY; error = falloc((vnode_t *)NULL, filemode, &fp, &fd); if (error == 0) { - if (auditing && (startvp != NULL)) + if (auditing && startvp != NULL) audit_setfsat_path(1); /* * Last arg is a don't-care term if @@ -259,13 +270,13 @@ out: return (set_errno(error)); } -#define OPENMODE32(fmode) ((int)((fmode)-FOPEN)) +#define OPENMODE32(fmode) (((fmode) & (FSEARCH | FEXEC))? \ + (fmode) : (fmode) - FOPEN) #define OPENMODE64(fmode) (OPENMODE32(fmode) | FOFFMAX) -#define OPENMODEATTRDIR FXATTRDIROPEN #ifdef _LP64 #define OPENMODE(fmode) OPENMODE64(fmode) #else -#define OPENMODE OPENMODE32 +#define OPENMODE(fmode) OPENMODE32(fmode) #endif /* diff --git a/usr/src/uts/common/syscall/readlink.c b/usr/src/uts/common/syscall/readlink.c index 4c31e16d3f..e88c842ba7 100644 --- a/usr/src/uts/common/syscall/readlink.c +++ b/usr/src/uts/common/syscall/readlink.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -31,8 +31,6 @@ * under license from the Regents of the University of California. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/param.h> #include <sys/isa_defs.h> #include <sys/types.h> @@ -43,16 +41,19 @@ #include <sys/pathname.h> #include <sys/vnode.h> #include <sys/file.h> +#include <sys/fcntl.h> #include <sys/uio.h> #include <sys/debug.h> #include <fs/fs_subr.h> +#include <c2/audit.h> /* * Read the contents of a symbolic link. */ ssize_t -readlink(char *name, char *buf, size_t count) +readlinkat(int dfd, char *name, char *buf, size_t count) { + vnode_t *startvp; vnode_t *vp; struct iovec aiov; struct uio auio; @@ -63,12 +64,19 @@ readlink(char *name, char *buf, size_t count) if ((cnt = (ssize_t)count) < 0) return (set_errno(EINVAL)); + if (name == NULL) + return (set_errno(EFAULT)); + if ((error = fgetstartvp(dfd, name, &startvp)) != 0) + return (set_errno(error)); lookup: - if (error = lookupname(name, UIO_USERSPACE, NO_FOLLOW, NULLVPP, &vp)) { - if ((error == ESTALE) && fs_need_estale_retry(estale_retry++)) + if (AU_AUDITING() && startvp != NULL) + audit_setfsat_path(1); + if (error = lookupnameat(name, UIO_USERSPACE, NO_FOLLOW, + NULLVPP, &vp, startvp)) { + if (error == ESTALE && fs_need_estale_retry(estale_retry++)) goto lookup; - return (set_errno(error)); + goto out; } if (vp->v_type != VLNK) { @@ -83,7 +91,8 @@ lookup: if ((error == ESTALE) && fs_need_estale_retry(estale_retry++)) goto lookup; - return (set_errno(EINVAL)); + error = EINVAL; + goto out; } } aiov.iov_base = buf; @@ -96,14 +105,22 @@ lookup: auio.uio_resid = cnt; error = VOP_READLINK(vp, &auio, CRED(), NULL); VN_RELE(vp); - if (error) { - if ((error == ESTALE) && fs_need_estale_retry(estale_retry++)) - goto lookup; + if (error == ESTALE && fs_need_estale_retry(estale_retry++)) + goto lookup; +out: + if (startvp != NULL) + VN_RELE(startvp); + if (error) return (set_errno(error)); - } return ((ssize_t)(cnt - auio.uio_resid)); } +ssize_t +readlink(char *name, char *buf, size_t count) +{ + return (readlinkat(AT_FDCWD, name, buf, count)); +} + #ifdef _SYSCALL32_IMPL /* * readlink32() intentionally returns a ssize_t rather than ssize32_t; @@ -111,9 +128,16 @@ lookup: */ ssize_t +readlinkat32(int dfd, caddr32_t name, caddr32_t buf, size32_t count) +{ + return ((ssize32_t)readlinkat(dfd, (char *)(uintptr_t)name, + (char *)(uintptr_t)buf, (ssize32_t)count)); +} + +ssize_t readlink32(caddr32_t name, caddr32_t buf, size32_t count) { - return ((ssize32_t)readlink((char *)(uintptr_t)name, + return ((ssize32_t)readlinkat(AT_FDCWD, (char *)(uintptr_t)name, (char *)(uintptr_t)buf, (ssize32_t)count)); } diff --git a/usr/src/uts/common/syscall/rename.c b/usr/src/uts/common/syscall/rename.c index 59344790c9..c6e4f08082 100644 --- a/usr/src/uts/common/syscall/rename.c +++ b/usr/src/uts/common/syscall/rename.c @@ -42,74 +42,39 @@ #include <sys/debug.h> #include <sys/file.h> #include <sys/fcntl.h> +#include <c2/audit.h> /* * Rename a file relative to a given directory */ int -renameat(int fromfd, char *old, int tofd, char *new) +renameat(int ffd, char *from, int tfd, char *to) { - vnode_t *fromvp = NULL; - vnode_t *tovp = NULL; - file_t *fp; + vnode_t *fstartvp = NULL; + vnode_t *tstartvp = NULL; int error; - char oldstart; - char newstart; - if (copyin(old, &oldstart, sizeof (char)) || - copyin(new, &newstart, sizeof (char))) + if (from == NULL || to == NULL) return (set_errno(EFAULT)); + if ((error = fgetstartvp(ffd, from, &fstartvp)) != 0) + goto out; + if ((error = fgetstartvp(tfd, to, &tstartvp)) != 0) + goto out; - if (fromfd == AT_FDCWD || tofd == AT_FDCWD) { - proc_t *p = curproc; + error = vn_renameat(fstartvp, from, tstartvp, to, UIO_USERSPACE); - mutex_enter(&p->p_lock); - if (fromfd == AT_FDCWD) { - fromvp = PTOU(p)->u_cdir; - VN_HOLD(fromvp); - } - if (tofd == AT_FDCWD) { - tovp = PTOU(p)->u_cdir; - VN_HOLD(tovp); - } - mutex_exit(&p->p_lock); - } - - if (fromvp == NULL && oldstart != '/') { - if ((fp = getf(fromfd)) == NULL) { - if (tovp != NULL) - VN_RELE(tovp); - return (set_errno(EBADF)); - } - fromvp = fp->f_vnode; - VN_HOLD(fromvp); - releasef(fromfd); - } - - if (tovp == NULL && newstart != '/') { - if ((fp = getf(tofd)) == NULL) { - if (fromvp != NULL) - VN_RELE(fromvp); - return (set_errno(EBADF)); - } - tovp = fp->f_vnode; - VN_HOLD(tovp); - releasef(tofd); - } - - error = vn_renameat(fromvp, old, tovp, new, UIO_USERSPACE); - - if (fromvp != NULL) - VN_RELE(fromvp); - if (tovp != NULL) - VN_RELE(tovp); +out: + if (fstartvp != NULL) + VN_RELE(fstartvp); + if (tstartvp != NULL) + VN_RELE(tstartvp); if (error) return (set_errno(error)); return (0); } int -rename(char *old, char *new) +rename(char *from, char *to) { - return (renameat(AT_FDCWD, old, AT_FDCWD, new)); + return (renameat(AT_FDCWD, from, AT_FDCWD, to)); } diff --git a/usr/src/uts/common/syscall/stat.c b/usr/src/uts/common/syscall/stat.c index d636b1c720..4085104cc7 100644 --- a/usr/src/uts/common/syscall/stat.c +++ b/usr/src/uts/common/syscall/stat.c @@ -102,7 +102,7 @@ cstatat_getvp(int fd, char *name, int follow, vnode_t **vp, cred_t **cred) } *cred = cr; - if (AU_AUDITING() && (startvp != NULL)) + if (AU_AUDITING() && startvp != NULL) audit_setfsat_path(1); lookup: diff --git a/usr/src/uts/common/syscall/symlink.c b/usr/src/uts/common/syscall/symlink.c index 99dcdf01a4..87fa7bee60 100644 --- a/usr/src/uts/common/syscall/symlink.c +++ b/usr/src/uts/common/syscall/symlink.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -40,6 +40,8 @@ #include <sys/pathname.h> #include <sys/vfs.h> #include <sys/vnode.h> +#include <sys/file.h> +#include <sys/fcntl.h> #include <sys/proc.h> #include <sys/uio.h> #include <sys/debug.h> @@ -51,8 +53,9 @@ * name is passed as string argument, not converted to vnode reference. */ int -symlink(char *target, char *linkname) +symlinkat(char *target, int dfd, char *linkname) { + vnode_t *startvp; vnode_t *dvp; struct vattr vattr; struct pathname lpn; @@ -60,15 +63,23 @@ symlink(char *target, char *linkname) size_t tlen; int error; int estale_retry = 0; + int auditing = AU_AUDITING(); + + if (linkname == NULL) + return (set_errno(EFAULT)); + if ((error = fgetstartvp(dfd, linkname, &startvp)) != 0) + return (set_errno(error)); top: if (error = pn_get(linkname, UIO_USERSPACE, &lpn)) - return (set_errno(error)); - if (error = lookuppn(&lpn, NULL, NO_FOLLOW, &dvp, NULLVPP)) { + goto out; + if (auditing && startvp != NULL) + audit_setfsat_path(2); + if (error = lookuppnat(&lpn, NULL, NO_FOLLOW, &dvp, NULLVPP, startvp)) { pn_free(&lpn); - if ((error == ESTALE) && fs_need_estale_retry(estale_retry++)) + if (error == ESTALE && fs_need_estale_retry(estale_retry++)) goto top; - return (set_errno(error)); + goto out; } if (vn_is_readonly(dvp)) error = EROFS; @@ -82,7 +93,7 @@ top: vattr.va_mask = AT_TYPE|AT_MODE; error = VOP_SYMLINK(dvp, lpn.pn_path, &vattr, tbuf, CRED(), NULL, 0); - if (AU_AUDITING()) + if (auditing) audit_symlink_create(dvp, lpn.pn_path, tbuf, error); } @@ -90,10 +101,18 @@ top: } pn_free(&lpn); VN_RELE(dvp); - if (error) { - if ((error == ESTALE) && fs_need_estale_retry(estale_retry++)) - goto top; + if (error == ESTALE && fs_need_estale_retry(estale_retry++)) + goto top; +out: + if (startvp != NULL) + VN_RELE(startvp); + if (error) return (set_errno(error)); - } return (0); } + +int +symlink(char *target, char *linkname) +{ + return (symlinkat(target, AT_FDCWD, linkname)); +} diff --git a/usr/src/uts/common/syscall/unlink.c b/usr/src/uts/common/syscall/unlink.c index 8ee0b9ff0d..8f48ad0d15 100644 --- a/usr/src/uts/common/syscall/unlink.c +++ b/usr/src/uts/common/syscall/unlink.c @@ -50,44 +50,21 @@ int unlinkat(int fd, char *name, int flags) { - file_t *dirfp; - vnode_t *dirvp; + vnode_t *startvp; int error; - char startchar; - if (fd == AT_FDCWD && name == NULL) + if (name == NULL) return (set_errno(EFAULT)); - - if (name != NULL) { - if (copyin(name, &startchar, sizeof (char))) - return (set_errno(EFAULT)); - } else - startchar = '\0'; - - if (fd == AT_FDCWD) { - dirvp = NULL; - } else { - if (startchar != '/') { - if ((dirfp = getf(fd)) == NULL) { - return (set_errno(EBADF)); - } - dirvp = dirfp->f_vnode; - VN_HOLD(dirvp); - releasef(fd); - } else { - dirvp = NULL; - } - } - - if (AU_AUDITING() && (dirvp != NULL)) + if ((error = fgetstartvp(fd, name, &startvp)) != 0) + return (set_errno(error)); + if (AU_AUDITING() && startvp != NULL) audit_setfsat_path(1); - error = vn_removeat(dirvp, name, - UIO_USERSPACE, (flags == AT_REMOVEDIR) ? RMDIRECTORY : RMFILE); - if (dirvp != NULL) - VN_RELE(dirvp); - - if (error != NULL) + error = vn_removeat(startvp, name, UIO_USERSPACE, + (flags == AT_REMOVEDIR) ? RMDIRECTORY : RMFILE); + if (startvp != NULL) + VN_RELE(startvp); + if (error) return (set_errno(error)); return (0); } diff --git a/usr/src/uts/common/syscall/utime.c b/usr/src/uts/common/syscall/utime.c index 19ce7bb972..36eddc90d2 100644 --- a/usr/src/uts/common/syscall/utime.c +++ b/usr/src/uts/common/syscall/utime.c @@ -83,10 +83,9 @@ cfutimesat(int fd, char *fname, int nmflag, vattr_t *vap, int flags, int follow) } } - if (AU_AUDITING() && (startvp != NULL)) - audit_setfsat_path(1); - if ((nmflag == 1) || ((nmflag == 2) && (fname != NULL))) { + if (AU_AUDITING() && startvp != NULL) + audit_setfsat_path(1); if ((error = lookupnameat(fname, UIO_USERSPACE, follow, NULLVPP, &vp, startvp)) != 0) { if (startvp != NULL) diff --git a/usr/src/uts/intel/os/name_to_sysnum b/usr/src/uts/intel/os/name_to_sysnum index e230d81afa..5e02b78d43 100644 --- a/usr/src/uts/intel/os/name_to_sysnum +++ b/usr/src/uts/intel/os/name_to_sysnum @@ -4,8 +4,10 @@ read 3 write 4 open 5 close 6 +linkat 7 link 9 unlink 10 +symlinkat 11 chdir 12 gtime 13 mknod 14 @@ -16,6 +18,7 @@ stat 18 lseek 19 getpid 20 mount 21 +readlinkat 22 setuid 23 getuid 24 stime 25 @@ -39,6 +42,7 @@ profil 44 faccessat 45 setgid 46 getgid 47 +mknodat 48 msgsys 49 sysi86 50 sysacct 51 @@ -89,6 +93,8 @@ sigaltstack 97 sigaction 98 sigpending 99 setcontext 100 +fchmodat 101 +mkdirat 102 statvfs 103 fstatvfs 104 getloadavg 105 diff --git a/usr/src/uts/sparc/os/name_to_sysnum b/usr/src/uts/sparc/os/name_to_sysnum index ab363d6216..8671ca5942 100644 --- a/usr/src/uts/sparc/os/name_to_sysnum +++ b/usr/src/uts/sparc/os/name_to_sysnum @@ -4,8 +4,10 @@ read 3 write 4 open 5 close 6 +linkat 7 link 9 unlink 10 +symlinkat 11 chdir 12 gtime 13 mknod 14 @@ -16,6 +18,7 @@ stat 18 lseek 19 getpid 20 mount 21 +readlinkat 22 setuid 23 getuid 24 stime 25 @@ -39,6 +42,7 @@ profil 44 faccessat 45 setgid 46 getgid 47 +mknodat 48 msgsys 49 sysacct 51 shmsys 52 @@ -88,6 +92,8 @@ sigaltstack 97 sigaction 98 sigpending 99 setcontext 100 +fchmodat 101 +mkdirat 102 statvfs 103 fstatvfs 104 getloadavg 105 |