View | Details | Raw Unified | Return to bug 180719
Collapse All | Expand All

(-)lib/libc/sys/Makefile.inc (-2 / +4 lines)
Lines 114-120 Link Here
114
	setgroups.2 setpgid.2 setregid.2 setresuid.2 setreuid.2 setsid.2 \
114
	setgroups.2 setpgid.2 setregid.2 setresuid.2 setreuid.2 setsid.2 \
115
	setuid.2 shmat.2 shmctl.2 shmget.2 shm_open.2 shutdown.2 \
115
	setuid.2 shmat.2 shmctl.2 shmget.2 shm_open.2 shutdown.2 \
116
	sigaction.2 sigaltstack.2 sigpending.2 sigprocmask.2 sigqueue.2 \
116
	sigaction.2 sigaltstack.2 sigpending.2 sigprocmask.2 sigqueue.2 \
117
	sigreturn.2 sigstack.2 sigsuspend.2 sigwait.2 sigwaitinfo.2 \
117
	sigreturn.2 sigsendset.2 sigstack.2 sigsuspend.2 \
118
	sigwait.2 sigwaitinfo.2 \
118
	socket.2 socketpair.2 stat.2 statfs.2 \
119
	socket.2 socketpair.2 stat.2 statfs.2 \
119
	swapon.2 symlink.2 sync.2 sysarch.2 syscall.2 \
120
	swapon.2 symlink.2 sync.2 sysarch.2 syscall.2 \
120
	timer_create.2 timer_delete.2 timer_settime.2 \
121
	timer_create.2 timer_delete.2 timer_settime.2 \
Lines 132-138 Link Here
132
MLINKS+=clock_gettime.2 clock_getres.2 clock_gettime.2 clock_settime.2
133
MLINKS+=clock_gettime.2 clock_getres.2 clock_gettime.2 clock_settime.2
133
MLINKS+=cpuset.2 cpuset_getid.2 cpuset.2 cpuset_setid.2
134
MLINKS+=cpuset.2 cpuset_getid.2 cpuset.2 cpuset_setid.2
134
MLINKS+=cpuset_getaffinity.2 cpuset_setaffinity.2
135
MLINKS+=cpuset_getaffinity.2 cpuset_setaffinity.2
135
MLINKS+=dup.2 dup2.2
136
MLINKS+=dup.2 dup2.2 dup.2 dup3.2
136
MLINKS+=execve.2 fexecve.2
137
MLINKS+=execve.2 fexecve.2
137
MLINKS+=extattr_get_file.2 extattr.2 \
138
MLINKS+=extattr_get_file.2 extattr.2 \
138
	extattr_get_file.2 extattr_delete_fd.2 \
139
	extattr_get_file.2 extattr_delete_fd.2 \
Lines 204-209 Link Here
204
MLINKS+=setuid.2 setegid.2 setuid.2 seteuid.2 setuid.2 setgid.2
205
MLINKS+=setuid.2 setegid.2 setuid.2 seteuid.2 setuid.2 setgid.2
205
MLINKS+=shmat.2 shmdt.2
206
MLINKS+=shmat.2 shmdt.2
206
MLINKS+=shm_open.2 shm_unlink.2
207
MLINKS+=shm_open.2 shm_unlink.2
208
MLINKS+=sigsendset.2 sigsend.2
207
MLINKS+=sigwaitinfo.2 sigtimedwait.2
209
MLINKS+=sigwaitinfo.2 sigtimedwait.2
208
MLINKS+=stat.2 fstat.2 stat.2 fstatat.2 stat.2 lstat.2
210
MLINKS+=stat.2 fstat.2 stat.2 fstatat.2 stat.2 lstat.2
209
MLINKS+=statfs.2 fstatfs.2
211
MLINKS+=statfs.2 fstatfs.2
(-)lib/libc/gen/Symbol.map (+1 lines)
Lines 382-392 Link Here
382
FBSD_1.3 {
382
FBSD_1.3 {
383
	 fdlopen;
383
	 fdlopen;
384
	__FreeBSD_libc_enter_restricted_mode;
384
	__FreeBSD_libc_enter_restricted_mode;
385
	getcontextx;
385
	getcontextx;
386
	gid_from_group;
386
	gid_from_group;
387
	nvis;
387
	nvis;
388
	pwcache_userdb;
388
	pwcache_userdb;
389
	pwcache_groupdb;
389
	pwcache_groupdb;
390
	sigsend;
390
	snvis;
391
	snvis;
391
	strenvisx;
392
	strenvisx;
392
	strnunvis;
393
	strnunvis;
(-)lib/libc/gen/Makefile.inc (-1 / +2 lines)
Lines 29-35 Link Here
29
	scandir.c seed48.c seekdir.c semctl.c \
29
	scandir.c seed48.c seekdir.c semctl.c \
30
	setdomainname.c sethostname.c setjmperr.c setmode.c \
30
	setdomainname.c sethostname.c setjmperr.c setmode.c \
31
	setproctitle.c setprogname.c siginterrupt.c siglist.c signal.c \
31
	setproctitle.c setprogname.c siginterrupt.c siglist.c signal.c \
32
	sigsetops.c sleep.c srand48.c statvfs.c stringlist.c strtofflags.c \
32
	sigsend.c sigsetops.c sleep.c \
33
	srand48.c statvfs.c stringlist.c strtofflags.c \
33
	sysconf.c sysctl.c sysctlbyname.c sysctlnametomib.c \
34
	sysconf.c sysctl.c sysctlbyname.c sysctlnametomib.c \
34
	syslog.c telldir.c termios.c time.c times.c timezone.c tls.c \
35
	syslog.c telldir.c termios.c time.c times.c timezone.c tls.c \
35
	ttyname.c ttyslot.c ualarm.c ulimit.c uname.c unvis-compat.c \
36
	ttyname.c ttyslot.c ualarm.c ulimit.c uname.c unvis-compat.c \
(-)lib/libc/include/namespace.h (+1 lines)
Lines 224-229 Link Here
224
#define		setsockopt			_setsockopt
224
#define		setsockopt			_setsockopt
225
/*#define		sigaction			_sigaction*/
225
/*#define		sigaction			_sigaction*/
226
#define		sigprocmask			_sigprocmask
226
#define		sigprocmask			_sigprocmask
227
#define		sigsendset			_sigsendset
227
#define		sigsuspend			_sigsuspend
228
#define		sigsuspend			_sigsuspend
228
#define		socket				_socket
229
#define		socket				_socket
229
#define		socketpair			_socketpair
230
#define		socketpair			_socketpair
(-)lib/libc/include/un-namespace.h (+1 lines)
Lines 205-210 Link Here
205
#undef		setsockopt
205
#undef		setsockopt
206
#undef		sigaction
206
#undef		sigaction
207
#undef		sigprocmask
207
#undef		sigprocmask
208
#undef		sigsendset
208
#undef		sigsuspend
209
#undef		sigsuspend
209
#undef		socket
210
#undef		socket
210
#undef		socketpair
211
#undef		socketpair
(-)sys/bsm/audit_kevents.h (+1 lines)
Lines 603-608 Link Here
603
#define	AUE_PDGETPID		43199	/* FreeBSD. */
603
#define	AUE_PDGETPID		43199	/* FreeBSD. */
604
#define	AUE_PDWAIT		43200	/* FreeBSD. */
604
#define	AUE_PDWAIT		43200	/* FreeBSD. */
605
#define	AUE_WAIT6		43201	/* FreeBSD. */
605
#define	AUE_WAIT6		43201	/* FreeBSD. */
606
#define	AUE_SIGSENDSET		43202	/* FreeBSD. */
606
607
607
/*
608
/*
608
 * Darwin BSM uses a number of AUE_O_* definitions, which are aliased to the
609
 * Darwin BSM uses a number of AUE_O_* definitions, which are aliased to the
(-)sys/kern/makesyscalls.sh (+1 lines)
Lines 153-158 Link Here
153
		printf "#include <sys/acl.h>\n" > sysarg
153
		printf "#include <sys/acl.h>\n" > sysarg
154
		printf "#include <sys/cpuset.h>\n" > sysarg
154
		printf "#include <sys/cpuset.h>\n" > sysarg
155
		printf "#include <sys/_semaphore.h>\n" > sysarg
155
		printf "#include <sys/_semaphore.h>\n" > sysarg
156
		printf "#include <sys/procset.h>\n" > sysarg
156
		printf "#include <sys/ucontext.h>\n\n" > sysarg
157
		printf "#include <sys/ucontext.h>\n\n" > sysarg
157
		printf "#include <bsm/audit_kevents.h>\n\n" > sysarg
158
		printf "#include <bsm/audit_kevents.h>\n\n" > sysarg
158
		printf "struct proc;\n\n" > sysarg
159
		printf "struct proc;\n\n" > sysarg
(-)sys/kern/syscalls.master (+2 lines)
Lines 952-956 Link Here
952
				    int *status, int options, \
952
				    int *status, int options, \
953
				    struct __wrusage *wrusage, \
953
				    struct __wrusage *wrusage, \
954
				    siginfo_t *info); }
954
				    siginfo_t *info); }
955
533	AUE_SIGSENDSET	STD	{ int sigsendset(procset_t *psp, int sig); }
956
955
; Please copy any additions and changes to the following compatability tables:
957
; Please copy any additions and changes to the following compatability tables:
956
; sys/compat/freebsd32/syscalls.master
958
; sys/compat/freebsd32/syscalls.master
(-)sys/sys/syscallsubr.h (+2 lines)
Lines 55-60 Link Here
55
struct stat;
55
struct stat;
56
struct thr_param;
56
struct thr_param;
57
struct __wrusage;
57
struct __wrusage;
58
struct __procset;
58
59
59
int	kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg,
60
int	kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg,
60
	    u_int buflen);
61
	    u_int buflen);
Lines 206-211 Link Here
206
int	kern_sigaltstack(struct thread *td, stack_t *ss, stack_t *oss);
207
int	kern_sigaltstack(struct thread *td, stack_t *ss, stack_t *oss);
207
int	kern_sigprocmask(struct thread *td, int how,
208
int	kern_sigprocmask(struct thread *td, int how,
208
	    sigset_t *set, sigset_t *oset, int flags);
209
	    sigset_t *set, sigset_t *oset, int flags);
210
int	kern_sigsendset (struct thread *td, struct __procset *ps, int sign);
209
int	kern_sigsuspend(struct thread *td, sigset_t mask);
211
int	kern_sigsuspend(struct thread *td, sigset_t mask);
210
int	kern_sigtimedwait(struct thread *td, sigset_t waitset,
212
int	kern_sigtimedwait(struct thread *td, sigset_t waitset,
211
	    struct ksiginfo *ksi, struct timespec *timeout);
213
	    struct ksiginfo *ksi, struct timespec *timeout);
(-)sys/compat/freebsd32/syscalls.master (+3 lines)
Lines 49-54 Link Here
49
#include <sys/sysproto.h>
49
#include <sys/sysproto.h>
50
#include <sys/mount.h>
50
#include <sys/mount.h>
51
#include <sys/socket.h>
51
#include <sys/socket.h>
52
#include <sys/procset.h>
52
#include <compat/freebsd32/freebsd32.h>
53
#include <compat/freebsd32/freebsd32.h>
53
#include <compat/freebsd32/freebsd32_proto.h>
54
#include <compat/freebsd32/freebsd32_proto.h>
54
55
Lines 1019-1021 Link Here
1019
				    struct wrusage32 *wrusage, \
1020
				    struct wrusage32 *wrusage, \
1020
				    siginfo_t *info); }
1021
				    siginfo_t *info); }
1021
#endif
1022
#endif
1023
533	AUE_SIGSENDSET	STD	{ int freebsd32_sigsendset(struct procset32 *psp, \
1024
				    int sig); }
(-)include/signal.h (+8 lines)
Lines 120-125 Link Here
120
int	sigstack(const struct sigstack *, struct sigstack *);
120
int	sigstack(const struct sigstack *, struct sigstack *);
121
int	sigvec(int, struct sigvec *, struct sigvec *);
121
int	sigvec(int, struct sigvec *, struct sigvec *);
122
#endif
122
#endif
123
124
#if __BSD_VISIBLE
125
#include <sys/procset.h>
126
127
int	sigsend(idtype_t idtype, id_t id, int sig);
128
int	sigsendset(procset_t *psetptr, int sig);
129
#endif
130
123
__END_DECLS
131
__END_DECLS
124
132
125
#endif /* !_SIGNAL_H_ */
133
#endif /* !_SIGNAL_H_ */
(-)sys/sys/wait.h (-39 / +1 lines)
Lines 88-133 Link Here
88
#define	WLINUXCLONE 0x80000000	/* Wait for kthread spawned from linux_clone. */
88
#define	WLINUXCLONE 0x80000000	/* Wait for kthread spawned from linux_clone. */
89
#endif
89
#endif
90
90
91
#ifndef _IDTYPE_T_DECLARED
91
#include <sys/_idtype.h>
92
typedef enum
93
#if __BSD_VISIBLE
94
	idtype		/* pollutes XPG4.2 namespace */
95
#endif
96
		{
97
	/*
98
	 * These names were mostly lifted from Solaris source code and
99
	 * still use Solaris style naming to avoid breaking any
100
	 * OpenSolaris code which has been ported to FreeBSD.  There
101
	 * is no clear FreeBSD counterpart for all of the names, but
102
	 * some have a clear correspondence to FreeBSD entities.
103
	 *
104
	 * The numerical values are kept synchronized with the Solaris
105
	 * values.
106
	 */
107
	P_PID,			/* A process identifier. */
108
	P_PPID,			/* A parent process identifier.	*/
109
	P_PGID,			/* A process group identifier. */
110
	P_SID,			/* A session identifier. */
111
	P_CID,			/* A scheduling class identifier. */
112
	P_UID,			/* A user identifier. */
113
	P_GID,			/* A group identifier. */
114
	P_ALL,			/* All processes. */
115
	P_LWPID,		/* An LWP identifier. */
116
	P_TASKID,		/* A task identifier. */
117
	P_PROJID,		/* A project identifier. */
118
	P_POOLID,		/* A pool identifier. */
119
	P_JAILID,		/* A zone identifier. */
120
	P_CTID,			/* A (process) contract identifier. */
121
	P_CPUID,		/* CPU identifier. */
122
	P_PSETID		/* Processor set identifier. */
123
} idtype_t;			/* The type of id_t we are using. */
124
92
125
#if __BSD_VISIBLE
126
#define	P_ZONEID	P_JAILID
127
#endif
128
#define	_IDTYPE_T_DECLARED
129
#endif
130
131
/*
93
/*
132
 * Tokens for special values of the "pid" parameter to wait4.
94
 * Tokens for special values of the "pid" parameter to wait4.
133
 * Extended struct __wrusage to collect rusage for both the target
95
 * Extended struct __wrusage to collect rusage for both the target
(-)sys/kern/kern_sig.c (+274 lines)
Lines 1714-1720 Link Here
1714
	/* NOTREACHED */
1714
	/* NOTREACHED */
1715
}
1715
}
1716
1716
1717
/*
1718
 * This shall be called only while holding both
1719
 * PROC_LOCK(me) and PROC_LOCK(p).
1720
 */
1721
static int
1722
pr_matches_id (me, p, idtype, id)
1723
	struct proc *me;
1724
	struct proc *p;
1725
	idtype_t    idtype;
1726
	id_t	    id;
1727
{
1728
	int ret = 0;		/* Assume no match. */
1729
1730
	switch (idtype) {
1731
	case P_ALL:
1732
		ret = 1;
1733
		break;
1734
	case P_PID:
1735
		if (id == P_MYID)
1736
		    id = (id_t)me->p_pid;
1737
		ret = (p->p_pid == (pid_t)id) ? 1 : 0;
1738
		break;
1739
	case P_PGID:
1740
		if (id == P_MYID)
1741
		    id = (id_t)me->p_pgid;
1742
		ret = (p->p_pgid == (pid_t)id) ? 1 : 0;
1743
		break;
1744
	case P_SID:
1745
		if (id == P_MYID)
1746
		    id = (id_t)me->p_session->s_sid;
1747
		ret = (p->p_session->s_sid == (pid_t)id) ? 1 : 0;
1748
		break;
1749
	case P_UID:
1750
		if (id == P_MYID)
1751
		    id = (id_t)me->p_ucred->cr_uid;
1752
		ret = (p->p_ucred->cr_uid == (uid_t)id) ? 1 : 0;
1753
		break;
1754
	case P_GID:
1755
		if (id == P_MYID)
1756
		    id = (id_t)me->p_ucred->cr_gid;
1757
		ret = (p->p_ucred->cr_gid == (gid_t)id) ? 1 : 0;
1758
		break;
1759
	case P_JAILID:
1760
		if (p->p_ucred->cr_prison == NULL)
1761
			return (0);
1762
		if (id == P_MYID) {
1763
			if (me->p_ucred->cr_prison == NULL)
1764
				return (0);
1765
			id = (id_t) me->p_ucred->cr_prison->pr_id;
1766
		}
1767
		ret = (p->p_ucred->cr_prison->pr_id == (int)id) ? 1 : 0;
1768
		break;
1769
	default:
1770
		/*
1771
		 * Currently no support for
1772
		 * P_CID, P_CPUID, P_PSETID, P_POOLID,
1773
		 * P_LWPID, P_CTID, P_TASKID, P_PROJID,
1774
		 * usw.
1775
		 */
1776
		return (0);
1777
		break;
1778
	}
1779
	return (ret);
1780
}
1781
1782
static int
1783
supported_sigsend_idtype (idtype)
1784
	idtype_t idtype;
1785
{
1786
	switch (idtype) {
1787
	case P_ALL:
1788
	case P_PID:
1789
	case P_PGID:
1790
	case P_SID:
1791
	case P_UID:
1792
	case P_GID:
1793
	case P_JAILID:
1794
		return (1);
1795
		break;
1796
	default:
1797
		/*
1798
		 * Currently no support for
1799
		 * P_CID, P_CPUID, P_PSETID, P_POOLID,
1800
		 * P_LWPID, P_CTID, P_TASKID, P_PROJID,
1801
		 * usw.
1802
		 */
1803
		break;
1804
	}
1805
	return (0);
1806
}
1807
1717
int
1808
int
1809
kern_sigsendset (td, ps, sig)
1810
	struct thread *td;
1811
	procset_t *ps;
1812
	int sig;
1813
{
1814
	ksiginfo_t ksi;
1815
	struct proc *p;
1816
	struct proc *me;
1817
	int error;
1818
	int ret;
1819
	int lmatch;
1820
	int rmatch;
1821
1822
	if ((u_int)sig > _SIG_MAXSIG)
1823
		return (EINVAL);
1824
1825
	AUDIT_ARG_SIGNUM(sig);
1826
	AUDIT_ARG_VALUE(ps->p_op);	/* XXX These 5 may be wrong! */
1827
	AUDIT_ARG_VALUE(ps->p_lidtype);
1828
	AUDIT_ARG_VALUE(ps->p_lid);
1829
	AUDIT_ARG_VALUE(ps->p_ridtype);
1830
	AUDIT_ARG_VALUE(ps->p_rid);
1831
1832
	if (!supported_sigsend_idtype(ps->p_lidtype) ||
1833
	    !supported_sigsend_idtype(ps->p_ridtype))
1834
		return (EINVAL);
1835
1836
	switch (ps->p_op) {
1837
	case POP_AND:
1838
	case POP_DIFF:
1839
	case POP_OR:
1840
	case POP_XOR:
1841
		break;
1842
	default:
1843
		return (EINVAL);
1844
		break;
1845
	}
1846
1847
	ksiginfo_init(&ksi);
1848
	ksi.ksi_signo = sig;
1849
	ksi.ksi_code = SI_USER;
1850
	ksi.ksi_pid = td->td_proc->p_pid;
1851
	ksi.ksi_uid = td->td_ucred->cr_ruid;
1852
1853
	me = td->td_proc;
1854
1855
	ret = ESRCH;
1856
	sx_slock(&allproc_lock);
1857
	FOREACH_PROC_IN_SYSTEM(p) {
1858
		PROC_LOCK(p);
1859
		PROC_LOCK(me);
1860
1861
		/*
1862
		 * Short circuit out all those processes which
1863
		 * we do not wish to touch in any case.
1864
		 *
1865
		 * This is simply for readability.
1866
		 * The compiler will certainly optimize these to
1867
		 * one larger OR condition block with a single body.
1868
		 */
1869
1870
		if ((p->p_pid == 0) || 
1871
		    ((p->p_flag & P_SYSTEM) || (p->p_state == PRS_NEW))) {
1872
			PROC_UNLOCK(me);
1873
			PROC_UNLOCK(p);
1874
			continue;
1875
		}
1876
		else if ((ps->p_lidtype != P_PID) &&
1877
			 ((p == me) || (p->p_pid == 1))) {
1878
			PROC_UNLOCK(me);
1879
			PROC_UNLOCK(p);
1880
			continue;
1881
		}
1882
		else if ((ps->p_ridtype != P_PID) &&
1883
			 ((p == me) || (p->p_pid == 1))) {
1884
			PROC_UNLOCK(me);
1885
			PROC_UNLOCK(p);
1886
			continue;
1887
		}
1888
1889
		switch (ps->p_op) {
1890
		case POP_OR:
1891
			if (!pr_matches_id (me, p,
1892
					    ps->p_lidtype, ps->p_lid) &&
1893
			    !pr_matches_id (me, p,
1894
					    ps->p_ridtype, ps->p_rid)) {
1895
				PROC_UNLOCK(me);
1896
				PROC_UNLOCK(p);
1897
				continue;
1898
			}
1899
			break;
1900
		case POP_AND:
1901
			if (!pr_matches_id (me, p,
1902
					    ps->p_lidtype, ps->p_lid) ||
1903
			    !pr_matches_id (me, p,
1904
					    ps->p_ridtype, ps->p_rid)) {
1905
				PROC_UNLOCK(me);
1906
				PROC_UNLOCK(p);
1907
				continue;
1908
			}
1909
			break;
1910
		case POP_DIFF:
1911
			if (!pr_matches_id (me, p,
1912
					    ps->p_lidtype, ps->p_lid) ||
1913
			    pr_matches_id (me, p,
1914
					   ps->p_ridtype, ps->p_rid)) {
1915
				PROC_UNLOCK(me);
1916
				PROC_UNLOCK(p);
1917
				continue;
1918
			}
1919
			break;
1920
		case POP_XOR:
1921
			lmatch = pr_matches_id (me, p,
1922
						ps->p_lidtype, ps->p_lid);
1923
			rmatch = pr_matches_id (me, p,
1924
						ps->p_ridtype, ps->p_rid);
1925
			/*
1926
			 *  NOTE! - The values are always either 0 or 1.
1927
			 *  So, we can use binary XOR here.
1928
			 */
1929
			if (! (lmatch ^ rmatch)) {
1930
				PROC_UNLOCK(me);
1931
				PROC_UNLOCK(p);
1932
				continue;
1933
			}
1934
			break;
1935
		default:
1936
			/*
1937
			 * We should never get here!
1938
			 */
1939
			PROC_UNLOCK(me);
1940
			PROC_UNLOCK(p);
1941
			ret = EINVAL;
1942
			goto Cleanup;
1943
			break;
1944
		}
1945
1946
		PROC_UNLOCK(me);
1947
1948
		error = p_cansignal(td, p, sig);
1949
		if (error == 0) {
1950
			if (sig)
1951
				pksignal(p, sig, &ksi);
1952
			ret = 0;
1953
		}
1954
		else if (ret == ESRCH)
1955
			ret = error;
1956
1957
		PROC_UNLOCK(p);
1958
	}
1959
Cleanup:
1960
	sx_sunlock(&allproc_lock);
1961
	return (ret);
1962
}
1963
1964
#ifndef _SYS_SYSPROTO_H_
1965
struct sigsendset_args {
1966
	procset_t   *psp;
1967
	int	    sig;
1968
};
1969
#endif
1970
int
1971
sys_sigsendset (td, uap)
1972
	struct thread *td;
1973
	struct sigsendset_args *uap;
1974
{
1975
	int error;
1976
	procset_t pset;
1977
1978
	if ((u_int)uap->sig > _SIG_MAXSIG)
1979
		return (EINVAL);
1980
1981
	if (uap->psp == NULL)
1982
		return (EFAULT);
1983
1984
	error = copyin(uap->psp, &pset, sizeof (pset));
1985
	if (error != 0)
1986
		return (error);
1987
1988
	return (kern_sigsendset (td, &pset, uap->sig));
1989
}
1990
1991
int
1718
sys_pdkill(td, uap)
1992
sys_pdkill(td, uap)
1719
	struct thread *td;
1993
	struct thread *td;
1720
	struct pdkill_args *uap;
1994
	struct pdkill_args *uap;
(-)sys/compat/freebsd32/freebsd32.h (+10 lines)
Lines 89-94 Link Here
89
	struct timeval32 it_value;
89
	struct timeval32 it_value;
90
};
90
};
91
91
92
struct procset32 {
93
	int32_t	p_op;
94
	int32_t p_lidtype;
95
	int32_t p_lid1;
96
	int32_t p_lid2;
97
	int32_t p_ridtype;
98
	int32_t p_rid1;
99
	int32_t p_rid2;
100
};
101
92
#define FREEBSD4_MNAMELEN        (88 - 2 * sizeof(int32_t)) /* size of on/from name bufs */
102
#define FREEBSD4_MNAMELEN        (88 - 2 * sizeof(int32_t)) /* size of on/from name bufs */
93
103
94
/* 4.x version */
104
/* 4.x version */
(-)sys/compat/freebsd32/freebsd32_misc.c (+25 lines)
Lines 210-215 Link Here
210
	return (error);
210
	return (error);
211
}
211
}
212
212
213
int
214
freebsd32_sigsendset (td, uap)
215
	struct thread *td;
216
	struct freebsd32_sigsendset_args *uap;
217
{
218
	int error;
219
	procset_t pset;
220
	struct procset32 pset32;
221
222
	if (uap->psp == NULL)
223
		return (EFAULT);
224
225
	error = copyin(uap->psp, &pset32, sizeof (pset32));
226
	if (error != 0)
227
		return (error);
228
229
	pset.p_op = pset32.p_op;
230
	pset.p_lidtype = pset32.p_lidtype;
231
	pset.p_lid = (id_t) PAIR32TO64 (int64_t, pset32.p_lid);
232
	pset.p_ridtype = pset32.p_ridtype;
233
	pset.p_rid = (id_t) PAIR32TO64 (int64_t, pset32.p_rid);
234
235
	return (kern_sigsendset (td, &pset, uap->sig));
236
}
237
213
#ifdef COMPAT_FREEBSD4
238
#ifdef COMPAT_FREEBSD4
214
static void
239
static void
215
copy_statfs(struct statfs *in, struct statfs32 *out)
240
copy_statfs(struct statfs *in, struct statfs32 *out)
(-)sys/sys/_idtype.h (+71 lines)
Added Link Here
1
/*-
2
 * Copyright (c) 2012-2013 Jukka A. Ukkonen
3
 *	All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
20
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
22
 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
23
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 *
25
 * $FreeBSD: stable/9/sys/sys/_idtype.h 244172 2012-12-13 06:17:05Z jau $
26
 */
27
28
#ifndef	_SYS__IDTYPE_H_
29
#define	_SYS__IDTYPE_H_
30
31
#ifndef _IDTYPE_T_DECLARED
32
typedef enum
33
#if __BSD_VISIBLE
34
	idtype		/* pollutes XPG4.2 namespace */
35
#endif
36
		{
37
	/*
38
	 * These names were mostly lifted from Solaris source code and
39
	 * still use Solaris style naming to avoid breaking any
40
	 * OpenSolaris code which has been ported to FreeBSD.  There
41
	 * is no clear FreeBSD counterpart for all of the names, but
42
	 * some have a clear correspondence to FreeBSD entities.
43
	 *
44
	 * The numerical values are kept synchronized with the Solaris
45
	 * values.
46
	 */
47
	P_PID,			/* A process identifier. */
48
	P_PPID,			/* A parent process identifier.	*/
49
	P_PGID,			/* A process group identifier. */
50
	P_SID,			/* A session identifier. */
51
	P_CID,			/* A scheduling class identifier. */
52
	P_UID,			/* A user identifier. */
53
	P_GID,			/* A group identifier. */
54
	P_ALL,			/* All processes. */
55
	P_LWPID,		/* An LWP identifier. */
56
	P_TASKID,		/* A task identifier. */
57
	P_PROJID,		/* A project identifier. */
58
	P_POOLID,		/* A pool identifier. */
59
	P_JAILID,		/* A zone identifier. */
60
	P_CTID,			/* A (process) contract identifier. */
61
	P_CPUID,		/* CPU identifier. */
62
	P_PSETID		/* Processor set identifier. */
63
} idtype_t;			/* The type of id_t we are using. */
64
65
#if __BSD_VISIBLE
66
#define	P_ZONEID	P_JAILID
67
#endif
68
#define	_IDTYPE_T_DECLARED
69
#endif
70
71
#endif
(-)sys/sys/procset.h (+55 lines)
Added Link Here
1
/*-
2
 * Copyright (c) 2012-2013 Jukka A. Ukkonen
3
 *	All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
20
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
22
 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
23
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 *
25
 * $FreeBSD: stable/9/sys/sys/procset.h 244172 2012-12-13 06:17:05Z jau $
26
 */
27
28
#ifndef	_SYS_PROCSET_H_
29
#define	_SYS_PROCSET_H_
30
31
#include <sys/types.h>
32
#include <sys/_idtype.h>
33
34
typedef	enum {
35
    POP_OR, POP_AND, POP_XOR, POP_DIFF, 
36
} idop_t;
37
38
struct __procset {
39
    idop_t	p_op;
40
    idtype_t	p_lidtype;
41
    id_t	p_lid;
42
    idtype_t	p_ridtype;
43
    id_t	p_rid;
44
};
45
46
typedef struct __procset    procset_t;
47
48
/*
49
 *  Notice!
50
 *  The true process ID 0 would be anyhow excluded as a target.
51
 */
52
53
#define	P_MYID	0
54
55
#endif
(-)lib/libc/sys/sigsendset.2 (+381 lines)
Added Link Here
1
.\" Copyright (c) 2012-2013  Jukka A. Ukkonen
2
.\"	All rights reserved.
3
.\"
4
.\" Redistribution and use in source and binary forms, with or without
5
.\" modification, are permitted provided that the following conditions
6
.\" are met:
7
.\" 1. Redistributions of source code must retain the above copyright
8
.\"    notice, this list of conditions and the following disclaimer.
9
.\" 2. Redistributions in binary form must reproduce the above copyright
10
.\"    notice, this list of conditions and the following disclaimer in the
11
.\"    documentation and/or other materials provided with the distribution.
12
.\"
13
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18
.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
19
.\" OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
21
.\" TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
22
.\" THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
23
.\" DAMAGE.
24
.\"
25
.\" $FreeBSD: stable/9/lib/libc/sys/sigsendset.2 241224 2012-10-05 14:20:53Z jau $
26
.\"
27
.Dd July 14, 2013
28
.Dt SIGSENDSET 2
29
.Os
30
.Sh NAME
31
.Nm sigsend ,
32
.Nm sigsendset
33
.Nd send a signal to a process or a group of processes
34
.Sh LIBRARY
35
.Lb libc
36
.Sh SYNOPSIS
37
.In signal.h
38
.Bd -literal
39
struct __procset {
40
        idop_t      p_op;
41
        idtype_t    p_lidtype;
42
        id_t        p_lid;
43
        idtype_t    p_ridtype;
44
        id_t        p_rid;
45
};
46
47
typedef struct __procset    procset_t;
48
.Ed
49
.Ft int
50
.Fo sigsend
51
.Fa "idtype_t idtype"
52
.Fa "id_t id"
53
.Fa "int sig"
54
.Fc
55
.Ft int
56
.Fo sigsendset
57
.Fa "procset_t *pset"
58
.Fa "int sig"
59
.Fc
60
.Sh DESCRIPTION
61
The
62
.Fn sigsend
63
function sends a signal to the process or group of processes specified
64
by
65
.Fa id
66
and
67
.Fa idtype .
68
The signal to be sent is specified by sig and is either 0 or one of
69
the values listed in
70
.In signal.h .
71
If
72
.Fa sig
73
is
74
.Dv 0
75
(the null signal), error checking is performed but no signal is actually sent.
76
This value can be used to check the validity of
77
.Fa id
78
and
79
.Fa idtype .
80
.Pp
81
The real or effective user
82
.Nm ID
83
of the the sending process must match the real or saved user ID of
84
 the receiving process, unless the sender is
85
.Nm root
86
or alternatively privileged through some privilege policy to send signals
87
to processes owned by other UIDs.
88
The signal can also be sent when 
89
.Fa sig
90
is
91
.Dv SIGCONT
92
and the sending  process has the same session ID as the receiving process.
93
.Pp
94
If
95
.Fa idtype
96
is
97
.Dv P_PID ,
98
.Fa sig
99
is sent to the process with process
100
.Nm ID
101
.Fa id .
102
.Pp
103
If
104
.Fa idtype
105
is
106
.Dv P_PGID ,
107
.Fa sig
108
is sent to all the processes with process groupd
109
.Nm ID
110
.Fa id .
111
.Pp
112
If
113
.Fa idtype
114
is
115
.Dv P_SID ,
116
.Fa sig
117
is sent to all the processes with session
118
.Nm ID
119
.Fa id .
120
.\" // No task consept in FreeBSD yet.
121
.\" .Pp
122
.\" If
123
.\" .Fa idtype
124
.\" is
125
.\" .Dv P_TASKID ,
126
.\" .Fa sig
127
.\" is sent to all the processes with task
128
.\" .Nm ID
129
.\" .Fa id .
130
.Pp
131
If
132
.Fa idtype
133
is
134
.Dv P_UID ,
135
.Fa sig
136
is sent to all processes with effective user
137
.Nm ID
138
.Fa id .
139
.Pp
140
If
141
.Fa idtype
142
is
143
.Dv P_GID ,
144
.Fa sig
145
is sent to all processes with effective group
146
.Nm ID
147
.Fa id .
148
.\" // No project consept in FreeBSD yet.
149
.\" .Pp
150
.\" If
151
.\" .Fa idtype
152
.\" is
153
.\" .Dv P_PROJID ,
154
.\" .Fa sig
155
.\" is sent to all the processes with project
156
.\" .Nm ID
157
.\" .Fa id .
158
.\" // The CID a.k.a. the scheduling class would be otherwise easy
159
.\" // but at the moment all scheduling class info is in the thread
160
.\" // structures.
161
.\" // Thus the process has no unique or primary scheduling class
162
.\" // of its own. :(
163
.\" .Pp
164
.\" If
165
.\" .Fa idtype
166
.\" is
167
.\" .Dv P_CID ,
168
.\" .Fa sig
169
.\" is sent to all the processes with scheduler class
170
.\" .Nm ID
171
.\" .Fa id .
172
.\" // No contract consept in FreeBSD yet.
173
.\" .Pp
174
.\" If
175
.\" .Fa idtype
176
.\" is
177
.\" .Dv P_CTID ,
178
.\" .Fa sig
179
.\" is sent to all the processes with process contract
180
.\" .Nm ID
181
.\" .Fa id .
182
.Pp
183
If
184
.Fa idtype
185
is
186
.Dv P_JAILID ,
187
.Fa sig
188
is sent to all processes running in jail
189
.Nm ID
190
.Fa id .
191
.Pp
192
If
193
.Fa idtype
194
is
195
.Dv P_ALL ,
196
.Fa sig
197
is sent to all processes that fall within the sender's privileges
198
and 
199
.Fa id
200
is ignored.
201
.Pp
202
If
203
.Fa id
204
is
205
.Dv P_MYID ,
206
the value of
207
.Fa id 
208
is taken from the current process.
209
.Pp
210
The process with a process 
211
.Nm ID
212
of
213
.Dv 0
214
always excluded.
215
The process with a process
216
.Nm ID
217
of
218
.Dv 1
219
is excluded unless the
220
.Fa idtype
221
is equal to
222
.Dv P_PID .
223
.Pp
224
The
225
.Fn sigsendset
226
function provides an alternate interface for sending signals to sets of
227
processes. This function sends signals to the set of processes specified by
228
.Fa pset .
229
.Fa pset
230
is a pointer to a structure of type
231
.Nm procset_t ,
232
defined in
233
.In sys/procset.h ,
234
which includes the members shown in the
235
.Nm SYNOPSIS
236
section above.
237
.Pp
238
The
239
.Fa p_lidtype
240
and
241
.Fa p_lid
242
members specify the
243
.Nm ID
244
type and
245
.Nm ID
246
of the "left" set of processes; the
247
.Fa p_ridtype
248
and
249
.Fa p_rid
250
members specify the
251
.Nm ID
252
type and
253
.Nm ID
254
of the "right" set of processes.
255
ID types and IDs are specified just as for the
256
.Fa idtype
257
and
258
.Fa id
259
arguments to
260
.Fn sigsend .
261
The
262
.Fa p_op
263
member specifies the operation to be performed on the two sets of
264
processes to get the set of processes the function is to apply to.
265
The valid value for
266
.Fa p_op
267
and the processes they specify are:
268
.Bl -tag -width Nm
269
.It Nm POP_DIFF
270
Set difference: processes in left set and not in right set.
271
.It Nm POP_AND
272
Set intersection: processes in both left and right sets.
273
.It Nm POP_OR
274
Set union: processes in either left or right set or in both.
275
.It Nm POP_XOR
276
Set exclusive-or: processes in either left or right set but in both.
277
.El
278
.Sh RETURN VALUES
279
.Rv -std sigsend sigsendset
280
.Sh ERRORS
281
The
282
.Fn sigsend
283
and
284
.Fn sigsendset
285
functions will fail if:
286
.Bl -tag -width Er
287
.It Bq Er EINVAL
288
The
289
.Fa sig
290
argument is not a valid signal number, or the
291
.Fa idtype
292
argument is not a supported idtype.
293
.It Bq Er EINVAL
294
The
295
.Fa sig
296
argument is
297
.Dv SIGKILL ,
298
.Fa idtype
299
is
300
.Dv P_PID
301
and
302
.Fa id
303
is
304
.Dv 1 .
305
.It Bq Er EPERM
306
The  effective user of the calling process does not
307
match the real or saved user ID of the receiving
308
process, the calling process does not have sufficient
309
privileges \fI(root)\fP, and the calling process is
310
not sending
311
.Dv SIGCONT
312
to a process that shares the same session ID.
313
.sp
314
The calling process does not have sufficient privileges
315
\fI(root)\fP and is trying to send a signal to a process
316
with a different session ID, even though the effective
317
user ID of the sender matches the real or saved ID of
318
the receiving process.
319
.It Bq Er ESRCH
320
No process can be found corresponding to that specified by
321
.Fa idtype
322
and
323
.Fa id .
324
.El
325
.Pp
326
The
327
.Fn sigsendset
328
function will also fail if:
329
.Bl -tag -width Er
330
.It Bq Er EFAULT
331
The
332
.Fa pset
333
argument points to an illegal address.
334
.El
335
.Sh SEE ALSO
336
.Xr kill 1 ,
337
.Xr kill 2 ,
338
.Xr getpid 2 ,
339
.Xr signal 2 ,
340
.Xr sigaction 2 ,
341
.Xr wait 2
342
.Sh STANDARDS
343
The functions
344
.Fn sigsend
345
and
346
.Fn sigsendset
347
are not required by any standards.
348
They are compatibility functions only.
349
These functions have been previously present
350
in multiple commercial
351
.Ux
352
versions.
353
At least
354
.Nm SunOS/Solaris ,
355
.Nm HP-UX ,
356
.Nm IRIX ,
357
and
358
.Nm Tru64
359
are examples of vendors which have included
360
these functions in their standard libraries.
361
.Sh NOTE
362
Though these functions provide flexibility and convenience in sending
363
signals to a large number of processes in a single function call and
364
though they allow specifying target processes using also other ID types
365
than
366
.Dv P_PID ,
367
.Dv P_PGID ,
368
and
369
.Dv P_ALL
370
which are available through the traditional
371
.Fn kill ,
372
using them in your code may limit portability
373
to operating systems which do not provide these
374
functions. \fI(e.g. Linux and AIX)\fP
375
.Sh AUTHOR
376
These APIs were implemented by Jukka A. Ukkonen, 2012-2013.
377
.sp
378
This manual page was converted to mdoc
379
by Jukka A. Ukkonen, 2013,
380
from its Solaris counterpart.
381
A few changes were introduced in the process.
(-)lib/libc/gen/sigsend.c (+49 lines)
Added Link Here
1
/*-
2
 * Copyright (c) 2012-2013 Jukka A. Ukkonen
3
 *	All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
20
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
22
 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
23
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 *
25
 * $FreeBSD: stable/9/sys/sys/_idtype.h 244172 2012-12-13 06:17:05Z jau $
26
 */
27
28
#include "namespace.h"
29
#include <sys/procset.h>
30
#include <signal.h>
31
#include "un-namespace.h"
32
33
int
34
__sigsend (idtype, id, sig)
35
    idtype_t	idtype;
36
    id_t	id;
37
    int		sig;
38
{
39
    procset_t	pset;
40
41
    pset.p_op = POP_OR;
42
    pset.p_lidtype = pset.p_ridtype = idtype;
43
    pset.p_lid = pset.p_rid = id;
44
45
    return (_sigsendset (&pset, sig));
46
}
47
48
__weak_reference(__sigsend, sigsend);
49
__weak_reference(__sigsend, _sigsend);

Return to bug 180719