VirtualBox

source: vbox/trunk/src/VBox/Installer/solaris/VBoxZoneAccess.c@ 35650

Last change on this file since 35650 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1/* $Id: VBoxZoneAccess.c 28800 2010-04-27 08:22:32Z vboxsync $ */
2/** @file
3 * VBoxZoneAccess - Hack that keeps vboxdrv referenced for granting zone access, Solaris hosts.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/*******************************************************************************
19* Header Files *
20*******************************************************************************/
21#include <stdio.h>
22#include <signal.h>
23#include <unistd.h>
24#include <fcntl.h>
25#include <errno.h>
26
27#include <iprt/process.h>
28
29#define DEVICE_NAME "/dev/vboxdrv"
30
31int main(int argc, char *argv[])
32{
33 int hDevice = -1;
34
35 /* Check root permissions. */
36 if (geteuid() != 0)
37 {
38 fprintf(stderr, "This program needs administrator privileges.\n");
39 return -1;
40 }
41
42 /* Daemonize... */
43 RTProcDaemonizeUsingFork(false /* fNoChDir */,
44 false /* fNoClose */,
45 NULL /* pszPidfile */);
46
47 /* Open the device */
48 hDevice = open(DEVICE_NAME, O_RDWR, 0);
49 if (hDevice < 0)
50 {
51 fprintf(stderr, "Failed to open '%s'. errno=%d\n", DEVICE_NAME, errno);
52 return errno;
53 }
54
55 /* Mark the file handle close on exec. */
56 if (fcntl(hDevice, F_SETFD, FD_CLOEXEC) != 0)
57 {
58 fprintf(stderr, "Failed to set close on exec. errno=%d\n", errno);
59 close(hDevice);
60 return errno;
61 }
62
63 /* Go to interruptible sleep for ~15 years... */
64 /* avoid > 2^31 for Year 2038 32-bit overflow (Solaris 10) */
65 sleep(500000000U);
66
67 close(hDevice);
68
69 return 0;
70}
71
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette