Changeset 6969 in vbox for trunk/src/VBox
- Timestamp:
- Feb 15, 2008 1:02:28 PM (17 years ago)
- Location:
- trunk/src/VBox/Additions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/installer/vboxadd.sh
r5999 r6969 110 110 modname=vboxadd 111 111 module=$kdir/$modname 112 owner=vboxadd 113 group=1 112 114 113 115 file="" … … 167 169 fi 168 170 171 chown $owner:$group $dev 2>/dev/null || { 172 rmmod $modname 2>/dev/null 173 fail "Cannot change owner $owner:$group for device $dev" 174 } 175 169 176 succ_msg 170 177 return 0 -
trunk/src/VBox/Additions/x11/xclient/main.cpp
r6459 r6969 29 29 #include <unistd.h> 30 30 #include <getopt.h> 31 #include <errno.h> 31 32 32 33 #include <X11/Xlib.h> … … 40 41 41 42 static bool gbDaemonise = true; 43 static int (*gpfnOldIOErrorHandler)(Display *) = NULL; 44 45 /** 46 * Drop the programmes privileges to the caller's. 47 * @returns IPRT status code 48 * @todo move this into the R3 guest library 49 */ 50 int vboxClientDropPrivileges(void) 51 { 52 int rc = VINF_SUCCESS; 53 int rcSystem, rcErrno; 54 55 #ifdef _POSIX_SAVED_IDS 56 rcSystem = setuid(getuid()); 57 #else 58 rcSystem = setreuid(-1, getuid()); 59 #endif 60 if (rcSystem < 0) 61 { 62 rcErrno = errno; 63 rc = RTErrConvertFromErrno(rcErrno); 64 LogRel(("VBoxClient: failed to drop privileges, error %Rrc.\n", rc)); 65 } 66 return rc; 67 } 42 68 43 69 /** … … 52 78 /* This can be triggered in debug builds if a guest application passes a bad atom 53 79 in its list of supported clipboard formats. As such it is harmless. */ 54 Log(("VBox Service: ignoring BadAtom error and returning\n"));80 Log(("VBoxClient: ignoring BadAtom error and returning\n")); 55 81 return 0; 56 82 } … … 58 84 { 59 85 /* This can be triggered if a guest application destroys a window before we notice. */ 60 Log(("VBox Service: ignoring BadWindow error and returning\n"));86 Log(("VBoxClient: ignoring BadWindow error and returning\n")); 61 87 return 0; 62 88 } … … 65 91 #endif 66 92 XGetErrorText(pDisplay, pError->error_code, errorText, sizeof(errorText)); 67 LogRel(("VBox Service: an X Window protocol error occurred: %s. Request code: %d, minor code: %d, serial number: %d\n",68 pError->error_code, pError->request_code, pError->minor_code, pError->serial));93 LogRel(("VBoxClient: an X Window protocol error occurred: %s (error code %d). Request code: %d, minor code: %d, serial number: %d\n", errorText, pError->error_code, pError->request_code, pError->minor_code, pError->serial)); 94 VbglR3Term(); 69 95 exit(1); 70 96 } 71 97 98 /** 99 * Xlib error handler for fatal errors. This often means that the programme is still running 100 * when X exits. 101 */ 102 int vboxClientXLibIOErrorHandler(Display *pDisplay) 103 { 104 Log(("VBoxClient: a fatal guest X Window error occurred. This may just mean that the Window system was shut down while the client was still running.\n")); 105 VbglR3Term(); 106 return gpfnOldIOErrorHandler(pDisplay); 107 } 108 72 109 int main(int argc, char *argv[]) 73 110 { 74 int rc ;111 int rcClipboard, rc; 75 112 #ifdef SEAMLESS_X11 76 113 /** Our instance of the seamless class. */ … … 114 151 if (RT_FAILURE(rc)) 115 152 { 116 LogRel(("VBoxService: failed to daemonize. exiting."));153 std::cout << "VBoxClient: failed to daemonize. exiting."<< std::endl; 117 154 return 1; 118 155 } … … 120 157 /* Initialise our runtime before all else. */ 121 158 RTR3Init(false); 122 rc = VbglR3Init(); 123 if (RT_FAILURE(rc)) 159 if (RT_FAILURE(VbglR3Init())) 124 160 { 125 161 std::cout << "Failed to connect to the VirtualBox kernel service" << std::endl; 126 162 return 1; 127 163 } 128 LogRel(("VBoxService: starting...\n")); 164 if (RT_FAILURE(vboxClientDropPrivileges())) 165 return 1; 166 LogRel(("VBoxClient: starting...\n")); 129 167 /* Initialise threading in X11 and in Xt. */ 130 168 if (!XInitThreads() || !XtToolkitThreadInitialize()) 131 169 { 132 LogRel(("VBox Service: error initialising threads in X11, exiting."));170 LogRel(("VBoxClient: error initialising threads in X11, exiting.")); 133 171 return 1; 134 172 } 135 173 /* Set an X11 error handler, so that we don't die when we get unavoidable errors. */ 136 174 XSetErrorHandler(vboxClientXLibErrorHandler); 175 /* Set an X11 I/O error handler, so that we can shutdown properly on fatal errors. */ 176 gpfnOldIOErrorHandler = XSetIOErrorHandler(vboxClientXLibIOErrorHandler); 137 177 #ifdef VBOX_X11_CLIPBOARD 138 178 /* Connect to the host clipboard. */ 139 LogRel(("VBox Service: starting clipboard Guest Additions...\n"));140 rc = vboxClipboardConnect();141 if (RT_ SUCCESS(rc))142 { 143 LogRel(("VBox Service: vboxClipboardConnect failed with rc = %Rrc\n", rc));179 LogRel(("VBoxClient: starting clipboard Guest Additions...\n")); 180 rcClipboard = vboxClipboardConnect(); 181 if (RT_FAILURE(rcClipboard)) 182 { 183 LogRel(("VBoxClient: vboxClipboardConnect failed with rc = %Rrc\n", rc)); 144 184 } 145 185 #endif /* VBOX_X11_CLIPBOARD defined */ … … 147 187 try 148 188 { 149 LogRel(("VBox Service: starting seamless Guest Additions...\n"));189 LogRel(("VBoxClient: starting seamless Guest Additions...\n")); 150 190 rc = seamless.init(); 151 191 if (RT_FAILURE(rc)) 152 192 { 153 LogRel(("VBox Service: failed to initialise seamless Additions, rc = %Rrc\n", rc));193 LogRel(("VBoxClient: failed to initialise seamless Additions, rc = %Rrc\n", rc)); 154 194 } 155 195 } 156 196 catch (std::exception e) 157 197 { 158 LogRel(("VBox Service: failed to initialise seamless Additions - caught exception: %s\n", e.what()));198 LogRel(("VBoxClient: failed to initialise seamless Additions - caught exception: %s\n", e.what())); 159 199 rc = VERR_UNRESOLVED_ERROR; 160 200 } 161 201 catch (...) 162 202 { 163 LogRel(("VBox Service: failed to initialise seamless Additions - caught unknown exception.\n"));203 LogRel(("VBoxClient: failed to initialise seamless Additions - caught unknown exception.\n")); 164 204 rc = VERR_UNRESOLVED_ERROR; 165 205 } 166 206 #endif /* SEAMLESS_X11 defined */ 167 207 #ifdef VBOX_X11_CLIPBOARD 168 LogRel(("VBoxService: connecting to the shared clipboard service.\n")); 169 vboxClipboardMain(); 170 vboxClipboardDisconnect(); 208 if (RT_SUCCESS(rcClipboard)) 209 { 210 LogRel(("VBoxClient: connecting to the shared clipboard service.\n")); 211 vboxClipboardMain(); 212 vboxClipboardDisconnect(); 213 } 171 214 #else /* VBOX_X11_CLIPBOARD not defined */ 172 LogRel(("VBox Service: sleeping...\n"));215 LogRel(("VBoxClient: sleeping...\n")); 173 216 pause(); 174 LogRel(("VBox Service: exiting...\n"));217 LogRel(("VBoxClient: exiting...\n")); 175 218 #endif /* VBOX_X11_CLIPBOARD not defined */ 176 219 #ifdef SEAMLESS_X11 … … 181 224 catch (std::exception e) 182 225 { 183 LogRel(("VBox Service: error shutting down seamless Additions - caught exception: %s\n", e.what()));226 LogRel(("VBoxClient: error shutting down seamless Additions - caught exception: %s\n", e.what())); 184 227 rc = VERR_UNRESOLVED_ERROR; 185 228 } 186 229 catch (...) 187 230 { 188 LogRel(("VBox Service: error shutting down seamless Additions - caught unknown exception.\n"));231 LogRel(("VBoxClient: error shutting down seamless Additions - caught unknown exception.\n")); 189 232 rc = VERR_UNRESOLVED_ERROR; 190 233 } 191 234 #endif /* SEAMLESS_X11 defined */ 192 return rc; 193 } 235 VbglR3Term(); 236 return RT_SUCCESS(rc) ? 0 : 1; 237 }
Note:
See TracChangeset
for help on using the changeset viewer.