PERFORCE change 79600 for review

Robert Watson rwatson at FreeBSD.org
Tue Jul 5 12:00:09 GMT 2005


http://perforce.freebsd.org/chv.cgi?CH=79600

Change 79600 by rwatson at rwatson_paprika on 2005/07/05 11:59:37

	Use CAP_SYS_ADMIN to authorize configuring swap (swapon(),
	swapoff()).

Affected files ...

.. //depot/projects/trustedbsd/sebsd/sys/vm/swap_pager.c#12 edit

Differences ...

==== //depot/projects/trustedbsd/sebsd/sys/vm/swap_pager.c#12 (text+ko) ====

@@ -1965,11 +1965,11 @@
 	struct nameidata nd;
 	int error;
 
-	mtx_lock(&Giant);
-	error = suser(td);
+	error = cap_check(td, CAP_SYS_ADMIN);
 	if (error)
-		goto done2;
+		return (error);
 
+	mtx_lock(&Giant);
 	while (swdev_syscall_active)
 	    tsleep(&swdev_syscall_active, PUSER - 1, "swpon", 0);
 	swdev_syscall_active = 1;
@@ -2008,7 +2008,6 @@
 done:
 	swdev_syscall_active = 0;
 	wakeup_one(&swdev_syscall_active);
-done2:
 	mtx_unlock(&Giant);
 	return (error);
 }
@@ -2105,12 +2104,12 @@
 	u_long nblks, dvbase;
 	int error;
 
+	error = cap_check(td, CAP_SYS_ADMIN);
+	if (error)
+		return (error);
+
 	mtx_lock(&Giant);
 
-	error = suser(td);
-	if (error)
-		goto done2;
-
 	while (swdev_syscall_active)
 	    tsleep(&swdev_syscall_active, PUSER - 1, "swpoff", 0);
 	swdev_syscall_active = 1;
@@ -2188,7 +2187,6 @@
 done:
 	swdev_syscall_active = 0;
 	wakeup_one(&swdev_syscall_active);
-done2:
 	mtx_unlock(&Giant);
 	return (error);
 }
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list