Deleted Added
sdiff udiff text old ( 229945 ) new ( 248297 )
full compact
1/*-
2 * Copyright (c) 2010 The FreeBSD Foundation
3 * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

--- 15 unchanged lines hidden (view full) ---

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sbin/hastd/subr.c 229945 2012-01-10 22:39:07Z pjd $");
33
34#ifdef HAVE_CAPSICUM
35#include <sys/capability.h>
36#endif
37#include <sys/param.h>
38#include <sys/disk.h>
39#include <sys/ioctl.h>
40#include <sys/jail.h>
41#include <sys/stat.h>
42
43#include <errno.h>
44#include <fcntl.h>
45#include <pwd.h>
46#include <stdarg.h>
47#include <stdbool.h>
48#include <stdio.h>
49#include <string.h>

--- 169 unchanged lines hidden (view full) ---

219 return (-1);
220 }
221 if (setuid(pw->pw_uid) == -1) {
222 pjdlog_errno(LOG_ERR, "Unable to set uid to %u",
223 (unsigned int)pw->pw_uid);
224 return (-1);
225 }
226
227 /*
228 * Until capsicum doesn't allow ioctl(2) we cannot use it to sandbox
229 * primary and secondary worker processes, as primary uses GGATE
230 * ioctls and secondary uses ioctls to handle BIO_DELETE and BIO_FLUSH.
231 * For now capsicum is only used to sandbox hastctl.
232 */
233#ifdef HAVE_CAPSICUM
234 if (res == NULL) {
235 capsicum = (cap_enter() == 0);
236 if (!capsicum) {
237 pjdlog_common(LOG_DEBUG, 1, errno,
238 "Unable to sandbox using capsicum");
239 }
240 } else
241#endif
242 capsicum = false;
243
244 /*
245 * Better be sure that everything succeeded.
246 */
247 PJDLOG_VERIFY(getresuid(&ruid, &euid, &suid) == 0);
248 PJDLOG_VERIFY(ruid == pw->pw_uid);
249 PJDLOG_VERIFY(euid == pw->pw_uid);
250 PJDLOG_VERIFY(suid == pw->pw_uid);

--- 14 unchanged lines hidden ---