1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-sysdeps-util.c Would be in dbus-sysdeps.c, but not used in libdbus
4 * Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc.
5 * Copyright (C) 2003 CodeFactory AB
7 * Licensed under the Academic Free License version 2.1
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 #define STRSAFE_NO_DEPRECATE
29 #include "dbus-sysdeps.h"
30 #include "dbus-internals.h"
31 #include "dbus-protocol.h"
32 #include "dbus-string.h"
33 #include "dbus-sysdeps.h"
34 #include "dbus-sysdeps-win.h"
35 #include "dbus-sockets-win.h"
36 #include "dbus-memory.h"
37 #include "dbus-pipe.h"
44 #include <winsock2.h> // WSA error codes
54 * Does the chdir, fork, setsid, etc. to become a daemon process.
56 * @param pidfile #NULL, or pidfile to create
57 * @param print_pid_pipe file descriptor to print daemon's pid to, or -1 for none
58 * @param error return location for errors
59 * @param keep_umask #TRUE to keep the original umask
60 * @returns #FALSE on failure
63 _dbus_become_daemon (const DBusString *pidfile,
64 DBusPipe *print_pid_pipe,
66 dbus_bool_t keep_umask)
68 dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
69 "Cannot daemonize on Windows");
74 * Creates a file containing the process ID.
76 * @param filename the filename to write to
77 * @param pid our process ID
78 * @param error return location for errors
79 * @returns #FALSE on failure
82 _dbus_write_pid_file (const DBusString *filename,
86 const char *cfilename;
92 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
94 cfilename = _dbus_string_get_const_data (filename);
96 hnd = CreateFileA (cfilename, GENERIC_WRITE,
97 FILE_SHARE_READ | FILE_SHARE_WRITE,
98 NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL,
99 INVALID_HANDLE_VALUE);
100 if (hnd == INVALID_HANDLE_VALUE)
102 char *emsg = _dbus_win_error_string (GetLastError ());
103 dbus_set_error (error, _dbus_win_error_from_last_error (),
104 "Could not create PID file %s: %s",
106 _dbus_win_free_error_string (emsg);
110 if (snprintf (pidstr, sizeof (pidstr), "%lu\n", pid) < 0)
112 dbus_set_error (error, _dbus_error_from_system_errno (),
113 "Failed to format PID for \"%s\": %s", cfilename,
114 _dbus_strerror_from_errno ());
120 bytes_to_write = strlen (pidstr);;
122 while (total < bytes_to_write)
127 res = WriteFile (hnd, pidstr + total, bytes_to_write - total,
128 &bytes_written, NULL);
130 if (res == 0 || bytes_written <= 0)
132 char *emsg = _dbus_win_error_string (GetLastError ());
133 dbus_set_error (error, _dbus_win_error_from_last_error (),
134 "Could not write to %s: %s", cfilename, emsg);
135 _dbus_win_free_error_string (emsg);
140 total += bytes_written;
143 if (CloseHandle (hnd) == 0)
145 char *emsg = _dbus_win_error_string (GetLastError ());
146 dbus_set_error (error, _dbus_win_error_from_last_error (),
147 "Could not close file %s: %s",
149 _dbus_win_free_error_string (emsg);
158 * Writes the given pid_to_write to a pidfile (if non-NULL) and/or to a
159 * pipe (if non-NULL). Does nothing if pidfile and print_pid_pipe are both
162 * @param pidfile the file to write to or #NULL
163 * @param print_pid_pipe the pipe to write to or #NULL
164 * @param pid_to_write the pid to write out
165 * @param error error on failure
166 * @returns FALSE if error is set
169 _dbus_write_pid_to_file_and_pipe (const DBusString *pidfile,
170 DBusPipe *print_pid_pipe,
171 dbus_pid_t pid_to_write,
176 _dbus_verbose ("writing pid file %s\n", _dbus_string_get_const_data (pidfile));
177 if (!_dbus_write_pid_file (pidfile,
181 _dbus_verbose ("pid file write failed\n");
182 _DBUS_ASSERT_ERROR_IS_SET(error);
188 _dbus_verbose ("No pid file requested\n");
191 if (print_pid_pipe != NULL && _dbus_pipe_is_valid (print_pid_pipe))
196 _dbus_verbose ("writing our pid to pipe %d\n", print_pid_pipe->fd);
198 if (!_dbus_string_init (&pid))
200 _DBUS_SET_OOM (error);
204 if (!_dbus_string_append_int (&pid, pid_to_write) ||
205 !_dbus_string_append (&pid, "\n"))
207 _dbus_string_free (&pid);
208 _DBUS_SET_OOM (error);
212 bytes = _dbus_string_get_length (&pid);
213 if (_dbus_pipe_write (print_pid_pipe, &pid, 0, bytes, error) != bytes)
215 /* _dbus_pipe_write sets error only on failure, not short write */
216 if (error != NULL && !dbus_error_is_set(error))
218 dbus_set_error (error, DBUS_ERROR_FAILED,
219 "Printing message bus PID: did not write enough bytes\n");
221 _dbus_string_free (&pid);
225 _dbus_string_free (&pid);
229 _dbus_verbose ("No pid pipe to write to\n");
236 * Verify that after the fork we can successfully change to this user.
238 * @param user the username given in the daemon configuration
239 * @returns #TRUE if username is valid
242 _dbus_verify_daemon_user (const char *user)
248 * Changes the user and group the bus is running as.
250 * @param user the user to become
251 * @param error return location for errors
252 * @returns #FALSE on failure
255 _dbus_change_to_daemon_user (const char *user,
262 fd_limit_not_supported (DBusError *error)
264 dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
265 "cannot change fd limit on this platform");
269 _dbus_rlimit_save_fd_limit (DBusError *error)
271 fd_limit_not_supported (error);
276 _dbus_rlimit_raise_fd_limit (DBusError *error)
278 fd_limit_not_supported (error);
283 _dbus_rlimit_restore_fd_limit (DBusRLimit *saved,
286 fd_limit_not_supported (error);
291 _dbus_rlimit_free (DBusRLimit *lim)
293 /* _dbus_rlimit_save_fd_limit() cannot return non-NULL on Windows
294 * so there cannot be anything to free */
295 _dbus_assert (lim == NULL);
301 * @param filename the filename to stat
302 * @param statbuf the stat info to fill in
303 * @param error return location for error
304 * @returns #FALSE if error was set
307 _dbus_stat(const DBusString *filename,
311 const char *filename_c;
312 WIN32_FILE_ATTRIBUTE_DATA wfad;
315 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
317 filename_c = _dbus_string_get_const_data (filename);
319 if (!GetFileAttributesExA (filename_c, GetFileExInfoStandard, &wfad))
321 _dbus_win_set_error_from_win_error (error, GetLastError ());
325 if (wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
326 statbuf->mode = _S_IFDIR;
328 statbuf->mode = _S_IFREG;
330 statbuf->mode |= _S_IREAD;
331 if (wfad.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
332 statbuf->mode |= _S_IWRITE;
334 lastdot = strrchr (filename_c, '.');
335 if (lastdot && stricmp (lastdot, ".exe") == 0)
336 statbuf->mode |= _S_IEXEC;
338 statbuf->mode |= (statbuf->mode & 0700) >> 3;
339 statbuf->mode |= (statbuf->mode & 0700) >> 6;
343 #ifdef ENABLE_UID_TO_SID
345 PSID owner_sid, group_sid;
346 PSECURITY_DESCRIPTOR sd;
349 rc = GetNamedSecurityInfo ((char *) filename_c, SE_FILE_OBJECT,
350 OWNER_SECURITY_INFORMATION |
351 GROUP_SECURITY_INFORMATION,
352 &owner_sid, &group_sid,
355 if (rc != ERROR_SUCCESS)
357 _dbus_win_set_error_from_win_error (error, rc);
364 statbuf->uid = _dbus_win_sid_to_uid_t (owner_sid);
365 statbuf->gid = _dbus_win_sid_to_uid_t (group_sid);
370 statbuf->uid = DBUS_UID_UNSET;
371 statbuf->gid = DBUS_GID_UNSET;
374 statbuf->size = ((dbus_int64_t) wfad.nFileSizeHigh << 32) + wfad.nFileSizeLow;
377 (((dbus_int64_t) wfad.ftLastAccessTime.dwHighDateTime << 32) +
378 wfad.ftLastAccessTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
381 (((dbus_int64_t) wfad.ftLastWriteTime.dwHighDateTime << 32) +
382 wfad.ftLastWriteTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
385 (((dbus_int64_t) wfad.ftCreationTime.dwHighDateTime << 32) +
386 wfad.ftCreationTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
392 * Internals of directory iterator
397 WIN32_FIND_DATAA fileinfo; /* from FindFirst/FindNext */
398 dbus_bool_t finished; /* true if there are no more entries */
403 * Open a directory to iterate over.
405 * @param filename the directory name
406 * @param error exception return object or #NULL
407 * @returns new iterator, or #NULL on error
410 _dbus_directory_open (const DBusString *filename,
416 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
418 if (!_dbus_string_init_from_string (&filespec, filename))
420 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
421 "Could not allocate memory for directory filename copy");
425 if (_dbus_string_ends_with_c_str (&filespec, "/") || _dbus_string_ends_with_c_str (&filespec, "\\") )
427 if (!_dbus_string_append (&filespec, "*"))
429 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
430 "Could not append filename wildcard");
434 else if (!_dbus_string_ends_with_c_str (&filespec, "*"))
436 if (!_dbus_string_append (&filespec, "\\*"))
438 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
439 "Could not append filename wildcard 2");
444 iter = dbus_new0 (DBusDirIter, 1);
447 _dbus_string_free (&filespec);
448 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
449 "Could not allocate memory for directory iterator");
453 iter->finished = FALSE;
455 iter->handle = FindFirstFileA (_dbus_string_get_const_data (&filespec), &(iter->fileinfo));
456 if (iter->handle == INVALID_HANDLE_VALUE)
458 if (GetLastError () == ERROR_NO_MORE_FILES)
459 iter->finished = TRUE;
462 char *emsg = _dbus_win_error_string (GetLastError ());
463 dbus_set_error (error, _dbus_win_error_from_last_error (),
464 "Failed to read directory \"%s\": %s",
465 _dbus_string_get_const_data (filename), emsg);
466 _dbus_win_free_error_string (emsg);
468 _dbus_string_free (&filespec);
472 _dbus_string_free (&filespec);
477 * Get next file in the directory. Will not return "." or ".." on
478 * UNIX. If an error occurs, the contents of "filename" are
479 * undefined. The error is never set if the function succeeds.
481 * @param iter the iterator
482 * @param filename string to be set to the next file in the dir
483 * @param error return location for error
484 * @returns #TRUE if filename was filled in with a new filename
487 _dbus_directory_get_next_file (DBusDirIter *iter,
488 DBusString *filename,
491 int saved_err = GetLastError();
493 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
498 if (!iter || iter->finished)
501 if (iter->offset > 0)
503 if (FindNextFileA (iter->handle, &(iter->fileinfo)) == 0)
505 if (GetLastError() == ERROR_NO_MORE_FILES)
507 SetLastError(saved_err);
512 char *emsg = _dbus_win_error_string (GetLastError ());
513 dbus_set_error (error, _dbus_win_error_from_last_error (),
514 "Failed to get next in directory: %s", emsg);
515 _dbus_win_free_error_string (emsg);
526 if (iter->fileinfo.cFileName[0] == '.' &&
527 (iter->fileinfo.cFileName[1] == '\0' ||
528 (iter->fileinfo.cFileName[1] == '.' && iter->fileinfo.cFileName[2] == '\0')))
531 _dbus_string_set_length (filename, 0);
532 if (!_dbus_string_append (filename, iter->fileinfo.cFileName))
534 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
535 "No memory to read directory entry");
543 * Closes a directory iteration.
546 _dbus_directory_close (DBusDirIter *iter)
550 FindClose(iter->handle);
554 /** @} */ /* End of DBusInternalsUtils functions */
557 * @addtogroup DBusString
562 * Get the directory name from a complete filename
563 * @param filename the filename
564 * @param dirname string to append directory name to
565 * @returns #FALSE if no memory
568 _dbus_string_get_dirname(const DBusString *filename,
573 _dbus_assert (filename != dirname);
574 _dbus_assert (filename != NULL);
575 _dbus_assert (dirname != NULL);
577 /* Ignore any separators on the end */
578 sep = _dbus_string_get_length (filename);
580 return _dbus_string_append (dirname, "."); /* empty string passed in */
583 (_dbus_string_get_byte (filename, sep - 1) == '/' ||
584 _dbus_string_get_byte (filename, sep - 1) == '\\'))
587 _dbus_assert (sep >= 0);
591 _dbus_string_get_byte (filename, 1) == ':' &&
592 isalpha (_dbus_string_get_byte (filename, 0))))
593 return _dbus_string_copy_len (filename, 0, sep + 1,
594 dirname, _dbus_string_get_length (dirname));
598 _dbus_string_find_byte_backward (filename, sep, '/', &sep1);
599 _dbus_string_find_byte_backward (filename, sep, '\\', &sep2);
601 sep = MAX (sep1, sep2);
604 return _dbus_string_append (dirname, ".");
607 (_dbus_string_get_byte (filename, sep - 1) == '/' ||
608 _dbus_string_get_byte (filename, sep - 1) == '\\'))
611 _dbus_assert (sep >= 0);
615 _dbus_string_get_byte (filename, 1) == ':' &&
616 isalpha (_dbus_string_get_byte (filename, 0))))
618 (_dbus_string_get_byte (filename, sep) == '/' ||
619 _dbus_string_get_byte (filename, sep) == '\\'))
620 return _dbus_string_copy_len (filename, 0, sep + 1,
621 dirname, _dbus_string_get_length (dirname));
623 return _dbus_string_copy_len (filename, 0, sep - 0,
624 dirname, _dbus_string_get_length (dirname));
629 * Checks to see if the UNIX user ID matches the UID of
630 * the process. Should always return #FALSE on Windows.
632 * @param uid the UNIX user ID
633 * @returns #TRUE if this uid owns the process.
636 _dbus_unix_user_is_process_owner (dbus_uid_t uid)
641 dbus_bool_t _dbus_windows_user_is_process_owner (const char *windows_sid)
646 /*=====================================================================
647 unix emulation functions - should be removed sometime in the future
648 =====================================================================*/
651 * Checks to see if the UNIX user ID is at the console.
652 * Should always fail on Windows (set the error to
653 * #DBUS_ERROR_NOT_SUPPORTED).
655 * @param uid UID of person to check
656 * @param error return location for errors
657 * @returns #TRUE if the UID is the same as the console user and there are no errors
660 _dbus_unix_user_is_at_console (dbus_uid_t uid,
663 dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
664 "UNIX user IDs not supported on Windows\n");
670 * Parse a UNIX group from the bus config file. On Windows, this should
671 * simply always fail (just return #FALSE).
673 * @param groupname the groupname text
674 * @param gid_p place to return the gid
675 * @returns #TRUE on success
678 _dbus_parse_unix_group_from_config (const DBusString *groupname,
685 * Parse a UNIX user from the bus config file. On Windows, this should
686 * simply always fail (just return #FALSE).
688 * @param username the username text
689 * @param uid_p place to return the uid
690 * @returns #TRUE on success
693 _dbus_parse_unix_user_from_config (const DBusString *username,
701 * Gets all groups corresponding to the given UNIX user ID. On UNIX,
702 * just calls _dbus_groups_from_uid(). On Windows, should always
703 * fail since we don't know any UNIX groups.
706 * @param group_ids return location for array of group IDs
707 * @param n_group_ids return location for length of returned array
708 * @returns #TRUE if the UID existed and we got some credentials
711 _dbus_unix_groups_from_uid (dbus_uid_t uid,
712 dbus_gid_t **group_ids,
720 /** @} */ /* DBusString stuff */
722 /************************************************************************
726 ************************************************************************/
732 /* lan manager error codes */
734 _dbus_lm_strerror(int error_number)
741 switch (error_number)
743 case NERR_NetNotStarted:
744 return "The workstation driver is not installed.";
745 case NERR_UnknownServer:
746 return "The server could not be located.";
748 return "An internal error occurred. The network cannot access a shared memory segment.";
749 case NERR_NoNetworkResource:
750 return "A network resource shortage occurred.";
751 case NERR_RemoteOnly:
752 return "This operation is not supported on workstations.";
753 case NERR_DevNotRedirected:
754 return "The device is not connected.";
755 case NERR_ServerNotStarted:
756 return "The Server service is not started.";
757 case NERR_ItemNotFound:
758 return "The queue is empty.";
759 case NERR_UnknownDevDir:
760 return "The device or directory does not exist.";
761 case NERR_RedirectedPath:
762 return "The operation is invalid on a redirected resource.";
763 case NERR_DuplicateShare:
764 return "The name has already been shared.";
766 return "The server is currently out of the requested resource.";
767 case NERR_TooManyItems:
768 return "Requested addition of items exceeds the maximum allowed.";
769 case NERR_InvalidMaxUsers:
770 return "The Peer service supports only two simultaneous users.";
771 case NERR_BufTooSmall:
772 return "The API return buffer is too small.";
774 return "A remote API error occurred.";
775 case NERR_LanmanIniError:
776 return "An error occurred when opening or reading the configuration file.";
777 case NERR_NetworkError:
778 return "A general network error occurred.";
779 case NERR_WkstaInconsistentState:
780 return "The Workstation service is in an inconsistent state. Restart the computer before restarting the Workstation service.";
781 case NERR_WkstaNotStarted:
782 return "The Workstation service has not been started.";
783 case NERR_BrowserNotStarted:
784 return "The requested information is not available.";
785 case NERR_InternalError:
786 return "An internal error occurred.";
787 case NERR_BadTransactConfig:
788 return "The server is not configured for transactions.";
789 case NERR_InvalidAPI:
790 return "The requested API is not supported on the remote server.";
791 case NERR_BadEventName:
792 return "The event name is invalid.";
793 case NERR_DupNameReboot:
794 return "The computer name already exists on the network. Change it and restart the computer.";
795 case NERR_CfgCompNotFound:
796 return "The specified component could not be found in the configuration information.";
797 case NERR_CfgParamNotFound:
798 return "The specified parameter could not be found in the configuration information.";
799 case NERR_LineTooLong:
800 return "A line in the configuration file is too long.";
802 return "The printer does not exist.";
803 case NERR_JobNotFound:
804 return "The print job does not exist.";
805 case NERR_DestNotFound:
806 return "The printer destination cannot be found.";
807 case NERR_DestExists:
808 return "The printer destination already exists.";
810 return "The printer queue already exists.";
812 return "No more printers can be added.";
814 return "No more print jobs can be added.";
815 case NERR_DestNoRoom:
816 return "No more printer destinations can be added.";
818 return "This printer destination is idle and cannot accept control operations.";
819 case NERR_DestInvalidOp:
820 return "This printer destination request contains an invalid control function.";
821 case NERR_ProcNoRespond:
822 return "The print processor is not responding.";
823 case NERR_SpoolerNotLoaded:
824 return "The spooler is not running.";
825 case NERR_DestInvalidState:
826 return "This operation cannot be performed on the print destination in its current state.";
827 case NERR_QInvalidState:
828 return "This operation cannot be performed on the printer queue in its current state.";
829 case NERR_JobInvalidState:
830 return "This operation cannot be performed on the print job in its current state.";
831 case NERR_SpoolNoMemory:
832 return "A spooler memory allocation failure occurred.";
833 case NERR_DriverNotFound:
834 return "The device driver does not exist.";
835 case NERR_DataTypeInvalid:
836 return "The data type is not supported by the print processor.";
837 case NERR_ProcNotFound:
838 return "The print processor is not installed.";
839 case NERR_ServiceTableLocked:
840 return "The service database is locked.";
841 case NERR_ServiceTableFull:
842 return "The service table is full.";
843 case NERR_ServiceInstalled:
844 return "The requested service has already been started.";
845 case NERR_ServiceEntryLocked:
846 return "The service does not respond to control actions.";
847 case NERR_ServiceNotInstalled:
848 return "The service has not been started.";
849 case NERR_BadServiceName:
850 return "The service name is invalid.";
851 case NERR_ServiceCtlTimeout:
852 return "The service is not responding to the control function.";
853 case NERR_ServiceCtlBusy:
854 return "The service control is busy.";
855 case NERR_BadServiceProgName:
856 return "The configuration file contains an invalid service program name.";
857 case NERR_ServiceNotCtrl:
858 return "The service could not be controlled in its present state.";
859 case NERR_ServiceKillProc:
860 return "The service ended abnormally.";
861 case NERR_ServiceCtlNotValid:
862 return "The requested pause or stop is not valid for this service.";
863 case NERR_NotInDispatchTbl:
864 return "The service control dispatcher could not find the service name in the dispatch table.";
865 case NERR_BadControlRecv:
866 return "The service control dispatcher pipe read failed.";
867 case NERR_ServiceNotStarting:
868 return "A thread for the new service could not be created.";
869 case NERR_AlreadyLoggedOn:
870 return "This workstation is already logged on to the local-area network.";
871 case NERR_NotLoggedOn:
872 return "The workstation is not logged on to the local-area network.";
873 case NERR_BadUsername:
874 return "The user name or group name parameter is invalid.";
875 case NERR_BadPassword:
876 return "The password parameter is invalid.";
877 case NERR_UnableToAddName_W:
878 return "@W The logon processor did not add the message alias.";
879 case NERR_UnableToAddName_F:
880 return "The logon processor did not add the message alias.";
881 case NERR_UnableToDelName_W:
882 return "@W The logoff processor did not delete the message alias.";
883 case NERR_UnableToDelName_F:
884 return "The logoff processor did not delete the message alias.";
885 case NERR_LogonsPaused:
886 return "Network logons are paused.";
887 case NERR_LogonServerConflict:
888 return "A centralized logon-server conflict occurred.";
889 case NERR_LogonNoUserPath:
890 return "The server is configured without a valid user path.";
891 case NERR_LogonScriptError:
892 return "An error occurred while loading or running the logon script.";
893 case NERR_StandaloneLogon:
894 return "The logon server was not specified. Your computer will be logged on as STANDALONE.";
895 case NERR_LogonServerNotFound:
896 return "The logon server could not be found.";
897 case NERR_LogonDomainExists:
898 return "There is already a logon domain for this computer.";
899 case NERR_NonValidatedLogon:
900 return "The logon server could not validate the logon.";
901 case NERR_ACFNotFound:
902 return "The security database could not be found.";
903 case NERR_GroupNotFound:
904 return "The group name could not be found.";
905 case NERR_UserNotFound:
906 return "The user name could not be found.";
907 case NERR_ResourceNotFound:
908 return "The resource name could not be found.";
909 case NERR_GroupExists:
910 return "The group already exists.";
911 case NERR_UserExists:
912 return "The user account already exists.";
913 case NERR_ResourceExists:
914 return "The resource permission list already exists.";
915 case NERR_NotPrimary:
916 return "This operation is only allowed on the primary domain controller of the domain.";
917 case NERR_ACFNotLoaded:
918 return "The security database has not been started.";
920 return "There are too many names in the user accounts database.";
921 case NERR_ACFFileIOFail:
922 return "A disk I/O failure occurred.";
923 case NERR_ACFTooManyLists:
924 return "The limit of 64 entries per resource was exceeded.";
926 return "Deleting a user with a session is not allowed.";
927 case NERR_ACFNoParent:
928 return "The parent directory could not be located.";
929 case NERR_CanNotGrowSegment:
930 return "Unable to add to the security database session cache segment.";
931 case NERR_SpeGroupOp:
932 return "This operation is not allowed on this special group.";
933 case NERR_NotInCache:
934 return "This user is not cached in user accounts database session cache.";
935 case NERR_UserInGroup:
936 return "The user already belongs to this group.";
937 case NERR_UserNotInGroup:
938 return "The user does not belong to this group.";
939 case NERR_AccountUndefined:
940 return "This user account is undefined.";
941 case NERR_AccountExpired:
942 return "This user account has expired.";
943 case NERR_InvalidWorkstation:
944 return "The user is not allowed to log on from this workstation.";
945 case NERR_InvalidLogonHours:
946 return "The user is not allowed to log on at this time.";
947 case NERR_PasswordExpired:
948 return "The password of this user has expired.";
949 case NERR_PasswordCantChange:
950 return "The password of this user cannot change.";
951 case NERR_PasswordHistConflict:
952 return "This password cannot be used now.";
953 case NERR_PasswordTooShort:
954 return "The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements.";
955 case NERR_PasswordTooRecent:
956 return "The password of this user is too recent to change.";
957 case NERR_InvalidDatabase:
958 return "The security database is corrupted.";
959 case NERR_DatabaseUpToDate:
960 return "No updates are necessary to this replicant network/local security database.";
961 case NERR_SyncRequired:
962 return "This replicant database is outdated; synchronization is required.";
963 case NERR_UseNotFound:
964 return "The network connection could not be found.";
965 case NERR_BadAsgType:
966 return "This asg_type is invalid.";
967 case NERR_DeviceIsShared:
968 return "This device is currently being shared.";
969 case NERR_NoComputerName:
970 return "The computer name could not be added as a message alias. The name may already exist on the network.";
971 case NERR_MsgAlreadyStarted:
972 return "The Messenger service is already started.";
973 case NERR_MsgInitFailed:
974 return "The Messenger service failed to start.";
975 case NERR_NameNotFound:
976 return "The message alias could not be found on the network.";
977 case NERR_AlreadyForwarded:
978 return "This message alias has already been forwarded.";
979 case NERR_AddForwarded:
980 return "This message alias has been added but is still forwarded.";
981 case NERR_AlreadyExists:
982 return "This message alias already exists locally.";
983 case NERR_TooManyNames:
984 return "The maximum number of added message aliases has been exceeded.";
985 case NERR_DelComputerName:
986 return "The computer name could not be deleted.";
987 case NERR_LocalForward:
988 return "Messages cannot be forwarded back to the same workstation.";
989 case NERR_GrpMsgProcessor:
990 return "An error occurred in the domain message processor.";
991 case NERR_PausedRemote:
992 return "The message was sent, but the recipient has paused the Messenger service.";
993 case NERR_BadReceive:
994 return "The message was sent but not received.";
996 return "The message alias is currently in use. Try again later.";
997 case NERR_MsgNotStarted:
998 return "The Messenger service has not been started.";
999 case NERR_NotLocalName:
1000 return "The name is not on the local computer.";
1001 case NERR_NoForwardName:
1002 return "The forwarded message alias could not be found on the network.";
1003 case NERR_RemoteFull:
1004 return "The message alias table on the remote station is full.";
1005 case NERR_NameNotForwarded:
1006 return "Messages for this alias are not currently being forwarded.";
1007 case NERR_TruncatedBroadcast:
1008 return "The broadcast message was truncated.";
1009 case NERR_InvalidDevice:
1010 return "This is an invalid device name.";
1011 case NERR_WriteFault:
1012 return "A write fault occurred.";
1013 case NERR_DuplicateName:
1014 return "A duplicate message alias exists on the network.";
1015 case NERR_DeleteLater:
1016 return "@W This message alias will be deleted later.";
1017 case NERR_IncompleteDel:
1018 return "The message alias was not successfully deleted from all networks.";
1019 case NERR_MultipleNets:
1020 return "This operation is not supported on computers with multiple networks.";
1021 case NERR_NetNameNotFound:
1022 return "This shared resource does not exist.";
1023 case NERR_DeviceNotShared:
1024 return "This device is not shared.";
1025 case NERR_ClientNameNotFound:
1026 return "A session does not exist with that computer name.";
1027 case NERR_FileIdNotFound:
1028 return "There is not an open file with that identification number.";
1029 case NERR_ExecFailure:
1030 return "A failure occurred when executing a remote administration command.";
1032 return "A failure occurred when opening a remote temporary file.";
1033 case NERR_TooMuchData:
1034 return "The data returned from a remote administration command has been truncated to 64K.";
1035 case NERR_DeviceShareConflict:
1036 return "This device cannot be shared as both a spooled and a non-spooled resource.";
1037 case NERR_BrowserTableIncomplete:
1038 return "The information in the list of servers may be incorrect.";
1039 case NERR_NotLocalDomain:
1040 return "The computer is not active in this domain.";
1041 #ifdef NERR_IsDfsShare
1043 case NERR_IsDfsShare:
1044 return "The share must be removed from the Distributed File System before it can be deleted.";
1047 case NERR_DevInvalidOpCode:
1048 return "The operation is invalid for this device.";
1049 case NERR_DevNotFound:
1050 return "This device cannot be shared.";
1051 case NERR_DevNotOpen:
1052 return "This device was not open.";
1053 case NERR_BadQueueDevString:
1054 return "This device name list is invalid.";
1055 case NERR_BadQueuePriority:
1056 return "The queue priority is invalid.";
1057 case NERR_NoCommDevs:
1058 return "There are no shared communication devices.";
1059 case NERR_QueueNotFound:
1060 return "The queue you specified does not exist.";
1061 case NERR_BadDevString:
1062 return "This list of devices is invalid.";
1064 return "The requested device is invalid.";
1065 case NERR_InUseBySpooler:
1066 return "This device is already in use by the spooler.";
1067 case NERR_CommDevInUse:
1068 return "This device is already in use as a communication device.";
1069 case NERR_InvalidComputer:
1070 return "This computer name is invalid.";
1071 case NERR_MaxLenExceeded:
1072 return "The string and prefix specified are too long.";
1073 case NERR_BadComponent:
1074 return "This path component is invalid.";
1076 return "Could not determine the type of input.";
1077 case NERR_TooManyEntries:
1078 return "The buffer for types is not big enough.";
1079 case NERR_ProfileFileTooBig:
1080 return "Profile files cannot exceed 64K.";
1081 case NERR_ProfileOffset:
1082 return "The start offset is out of range.";
1083 case NERR_ProfileCleanup:
1084 return "The system cannot delete current connections to network resources.";
1085 case NERR_ProfileUnknownCmd:
1086 return "The system was unable to parse the command line in this file.";
1087 case NERR_ProfileLoadErr:
1088 return "An error occurred while loading the profile file.";
1089 case NERR_ProfileSaveErr:
1090 return "@W Errors occurred while saving the profile file. The profile was partially saved.";
1091 case NERR_LogOverflow:
1092 return "Log file %1 is full.";
1093 case NERR_LogFileChanged:
1094 return "This log file has changed between reads.";
1095 case NERR_LogFileCorrupt:
1096 return "Log file %1 is corrupt.";
1097 case NERR_SourceIsDir:
1098 return "The source path cannot be a directory.";
1099 case NERR_BadSource:
1100 return "The source path is illegal.";
1102 return "The destination path is illegal.";
1103 case NERR_DifferentServers:
1104 return "The source and destination paths are on different servers.";
1105 case NERR_RunSrvPaused:
1106 return "The Run server you requested is paused.";
1107 case NERR_ErrCommRunSrv:
1108 return "An error occurred when communicating with a Run server.";
1109 case NERR_ErrorExecingGhost:
1110 return "An error occurred when starting a background process.";
1111 case NERR_ShareNotFound:
1112 return "The shared resource you are connected to could not be found.";
1113 case NERR_InvalidLana:
1114 return "The LAN adapter number is invalid.";
1115 case NERR_OpenFiles:
1116 return "There are open files on the connection.";
1117 case NERR_ActiveConns:
1118 return "Active connections still exist.";
1119 case NERR_BadPasswordCore:
1120 return "This share name or password is invalid.";
1122 return "The device is being accessed by an active process.";
1123 case NERR_LocalDrive:
1124 return "The drive letter is in use locally.";
1125 case NERR_AlertExists:
1126 return "The specified client is already registered for the specified event.";
1127 case NERR_TooManyAlerts:
1128 return "The alert table is full.";
1129 case NERR_NoSuchAlert:
1130 return "An invalid or nonexistent alert name was raised.";
1131 case NERR_BadRecipient:
1132 return "The alert recipient is invalid.";
1133 case NERR_AcctLimitExceeded:
1134 return "A user's session with this server has been deleted.";
1135 case NERR_InvalidLogSeek:
1136 return "The log file does not contain the requested record number.";
1137 case NERR_BadUasConfig:
1138 return "The user accounts database is not configured correctly.";
1139 case NERR_InvalidUASOp:
1140 return "This operation is not permitted when the Netlogon service is running.";
1141 case NERR_LastAdmin:
1142 return "This operation is not allowed on the last administrative account.";
1143 case NERR_DCNotFound:
1144 return "Could not find domain controller for this domain.";
1145 case NERR_LogonTrackingError:
1146 return "Could not set logon information for this user.";
1147 case NERR_NetlogonNotStarted:
1148 return "The Netlogon service has not been started.";
1149 case NERR_CanNotGrowUASFile:
1150 return "Unable to add to the user accounts database.";
1151 case NERR_TimeDiffAtDC:
1152 return "This server's clock is not synchronized with the primary domain controller's clock.";
1153 case NERR_PasswordMismatch:
1154 return "A password mismatch has been detected.";
1155 case NERR_NoSuchServer:
1156 return "The server identification does not specify a valid server.";
1157 case NERR_NoSuchSession:
1158 return "The session identification does not specify a valid session.";
1159 case NERR_NoSuchConnection:
1160 return "The connection identification does not specify a valid connection.";
1161 case NERR_TooManyServers:
1162 return "There is no space for another entry in the table of available servers.";
1163 case NERR_TooManySessions:
1164 return "The server has reached the maximum number of sessions it supports.";
1165 case NERR_TooManyConnections:
1166 return "The server has reached the maximum number of connections it supports.";
1167 case NERR_TooManyFiles:
1168 return "The server cannot open more files because it has reached its maximum number.";
1169 case NERR_NoAlternateServers:
1170 return "There are no alternate servers registered on this server.";
1171 case NERR_TryDownLevel:
1172 return "Try down-level (remote admin protocol) version of API instead.";
1173 case NERR_UPSDriverNotStarted:
1174 return "The UPS driver could not be accessed by the UPS service.";
1175 case NERR_UPSInvalidConfig:
1176 return "The UPS service is not configured correctly.";
1177 case NERR_UPSInvalidCommPort:
1178 return "The UPS service could not access the specified Comm Port.";
1179 case NERR_UPSSignalAsserted:
1180 return "The UPS indicated a line fail or low battery situation. Service not started.";
1181 case NERR_UPSShutdownFailed:
1182 return "The UPS service failed to perform a system shut down.";
1183 case NERR_BadDosRetCode:
1184 return "The program below returned an MS-DOS error code:";
1185 case NERR_ProgNeedsExtraMem:
1186 return "The program below needs more memory:";
1187 case NERR_BadDosFunction:
1188 return "The program below called an unsupported MS-DOS function:";
1189 case NERR_RemoteBootFailed:
1190 return "The workstation failed to boot.";
1191 case NERR_BadFileCheckSum:
1192 return "The file below is corrupt.";
1193 case NERR_NoRplBootSystem:
1194 return "No loader is specified in the boot-block definition file.";
1195 case NERR_RplLoadrNetBiosErr:
1196 return "NetBIOS returned an error: The NCB and SMB are dumped above.";
1197 case NERR_RplLoadrDiskErr:
1198 return "A disk I/O error occurred.";
1199 case NERR_ImageParamErr:
1200 return "Image parameter substitution failed.";
1201 case NERR_TooManyImageParams:
1202 return "Too many image parameters cross disk sector boundaries.";
1203 case NERR_NonDosFloppyUsed:
1204 return "The image was not generated from an MS-DOS diskette formatted with /S.";
1205 case NERR_RplBootRestart:
1206 return "Remote boot will be restarted later.";
1207 case NERR_RplSrvrCallFailed:
1208 return "The call to the Remoteboot server failed.";
1209 case NERR_CantConnectRplSrvr:
1210 return "Cannot connect to the Remoteboot server.";
1211 case NERR_CantOpenImageFile:
1212 return "Cannot open image file on the Remoteboot server.";
1213 case NERR_CallingRplSrvr:
1214 return "Connecting to the Remoteboot server...";
1215 case NERR_StartingRplBoot:
1216 return "Connecting to the Remoteboot server...";
1217 case NERR_RplBootServiceTerm:
1218 return "Remote boot service was stopped; check the error log for the cause of the problem.";
1219 case NERR_RplBootStartFailed:
1220 return "Remote boot startup failed; check the error log for the cause of the problem.";
1221 case NERR_RPL_CONNECTED:
1222 return "A second connection to a Remoteboot resource is not allowed.";
1223 case NERR_BrowserConfiguredToNotRun:
1224 return "The browser service was configured with MaintainServerList=No.";
1225 case NERR_RplNoAdaptersStarted:
1226 return "Service failed to start since none of the network adapters started with this service.";
1227 case NERR_RplBadRegistry:
1228 return "Service failed to start due to bad startup information in the registry.";
1229 case NERR_RplBadDatabase:
1230 return "Service failed to start because its database is absent or corrupt.";
1231 case NERR_RplRplfilesShare:
1232 return "Service failed to start because RPLFILES share is absent.";
1233 case NERR_RplNotRplServer:
1234 return "Service failed to start because RPLUSER group is absent.";
1235 case NERR_RplCannotEnum:
1236 return "Cannot enumerate service records.";
1237 case NERR_RplWkstaInfoCorrupted:
1238 return "Workstation record information has been corrupted.";
1239 case NERR_RplWkstaNotFound:
1240 return "Workstation record was not found.";
1241 case NERR_RplWkstaNameUnavailable:
1242 return "Workstation name is in use by some other workstation.";
1243 case NERR_RplProfileInfoCorrupted:
1244 return "Profile record information has been corrupted.";
1245 case NERR_RplProfileNotFound:
1246 return "Profile record was not found.";
1247 case NERR_RplProfileNameUnavailable:
1248 return "Profile name is in use by some other profile.";
1249 case NERR_RplProfileNotEmpty:
1250 return "There are workstations using this profile.";
1251 case NERR_RplConfigInfoCorrupted:
1252 return "Configuration record information has been corrupted.";
1253 case NERR_RplConfigNotFound:
1254 return "Configuration record was not found.";
1255 case NERR_RplAdapterInfoCorrupted:
1256 return "Adapter ID record information has been corrupted.";
1257 case NERR_RplInternal:
1258 return "An internal service error has occurred.";
1259 case NERR_RplVendorInfoCorrupted:
1260 return "Vendor ID record information has been corrupted.";
1261 case NERR_RplBootInfoCorrupted:
1262 return "Boot block record information has been corrupted.";
1263 case NERR_RplWkstaNeedsUserAcct:
1264 return "The user account for this workstation record is missing.";
1265 case NERR_RplNeedsRPLUSERAcct:
1266 return "The RPLUSER local group could not be found.";
1267 case NERR_RplBootNotFound:
1268 return "Boot block record was not found.";
1269 case NERR_RplIncompatibleProfile:
1270 return "Chosen profile is incompatible with this workstation.";
1271 case NERR_RplAdapterNameUnavailable:
1272 return "Chosen network adapter ID is in use by some other workstation.";
1273 case NERR_RplConfigNotEmpty:
1274 return "There are profiles using this configuration.";
1275 case NERR_RplBootInUse:
1276 return "There are workstations, profiles, or configurations using this boot block.";
1277 case NERR_RplBackupDatabase:
1278 return "Service failed to backup Remoteboot database.";
1279 case NERR_RplAdapterNotFound:
1280 return "Adapter record was not found.";
1281 case NERR_RplVendorNotFound:
1282 return "Vendor record was not found.";
1283 case NERR_RplVendorNameUnavailable:
1284 return "Vendor name is in use by some other vendor record.";
1285 case NERR_RplBootNameUnavailable:
1286 return "(boot name, vendor ID) is in use by some other boot block record.";
1287 case NERR_RplConfigNameUnavailable:
1288 return "Configuration name is in use by some other configuration.";
1289 case NERR_DfsInternalCorruption:
1290 return "The internal database maintained by the Dfs service is corrupt.";
1291 case NERR_DfsVolumeDataCorrupt:
1292 return "One of the records in the internal Dfs database is corrupt.";
1293 case NERR_DfsNoSuchVolume:
1294 return "There is no DFS name whose entry path matches the input Entry Path.";
1295 case NERR_DfsVolumeAlreadyExists:
1296 return "A root or link with the given name already exists.";
1297 case NERR_DfsAlreadyShared:
1298 return "The server share specified is already shared in the Dfs.";
1299 case NERR_DfsNoSuchShare:
1300 return "The indicated server share does not support the indicated DFS namespace.";
1301 case NERR_DfsNotALeafVolume:
1302 return "The operation is not valid on this portion of the namespace.";
1303 case NERR_DfsLeafVolume:
1304 return "The operation is not valid on this portion of the namespace.";
1305 case NERR_DfsVolumeHasMultipleServers:
1306 return "The operation is ambiguous because the link has multiple servers.";
1307 case NERR_DfsCantCreateJunctionPoint:
1308 return "Unable to create a link.";
1309 case NERR_DfsServerNotDfsAware:
1310 return "The server is not Dfs Aware.";
1311 case NERR_DfsBadRenamePath:
1312 return "The specified rename target path is invalid.";
1313 case NERR_DfsVolumeIsOffline:
1314 return "The specified DFS link is offline.";
1315 case NERR_DfsNoSuchServer:
1316 return "The specified server is not a server for this link.";
1317 case NERR_DfsCyclicalName:
1318 return "A cycle in the Dfs name was detected.";
1319 case NERR_DfsNotSupportedInServerDfs:
1320 return "The operation is not supported on a server-based Dfs.";
1321 case NERR_DfsDuplicateService:
1322 return "This link is already supported by the specified server-share.";
1323 case NERR_DfsCantRemoveLastServerShare:
1324 return "Can't remove the last server-share supporting this root or link.";
1325 case NERR_DfsVolumeIsInterDfs:
1326 return "The operation is not supported for an Inter-DFS link.";
1327 case NERR_DfsInconsistent:
1328 return "The internal state of the Dfs Service has become inconsistent.";
1329 case NERR_DfsServerUpgraded:
1330 return "The Dfs Service has been installed on the specified server.";
1331 case NERR_DfsDataIsIdentical:
1332 return "The Dfs data being reconciled is identical.";
1333 case NERR_DfsCantRemoveDfsRoot:
1334 return "The DFS root cannot be deleted. Uninstall DFS if required.";
1335 case NERR_DfsChildOrParentInDfs:
1336 return "A child or parent directory of the share is already in a Dfs.";
1337 case NERR_DfsInternalError:
1338 return "Dfs internal error.";
1339 /* the following are not defined in mingw */
1342 case NERR_SetupAlreadyJoined:
1343 return "This machine is already joined to a domain.";
1344 case NERR_SetupNotJoined:
1345 return "This machine is not currently joined to a domain.";
1346 case NERR_SetupDomainController:
1347 return "This machine is a domain controller and cannot be unjoined from a domain.";
1348 case NERR_DefaultJoinRequired:
1349 return "The destination domain controller does not support creating machine accounts in OUs.";
1350 case NERR_InvalidWorkgroupName:
1351 return "The specified workgroup name is invalid.";
1352 case NERR_NameUsesIncompatibleCodePage:
1353 return "The specified computer name is incompatible with the default language used on the domain controller.";
1354 case NERR_ComputerAccountNotFound:
1355 return "The specified computer account could not be found.";
1356 case NERR_PersonalSku:
1357 return "This version of Windows cannot be joined to a domain.";
1358 case NERR_PasswordMustChange:
1359 return "The password must change at the next logon.";
1360 case NERR_AccountLockedOut:
1361 return "The account is locked out.";
1362 case NERR_PasswordTooLong:
1363 return "The password is too long.";
1364 case NERR_PasswordNotComplexEnough:
1365 return "The password does not meet the complexity policy.";
1366 case NERR_PasswordFilterError:
1367 return "The password does not meet the requirements of the password filter DLLs.";
1371 msg = strerror (error_number);
1382 * Get a printable string describing the command used to execute
1383 * the process with pid. This string should only be used for
1384 * informative purposes such as logging; it may not be trusted.
1386 * The command is guaranteed to be printable ASCII and no longer
1389 * @param pid Process id
1390 * @param str Append command to this string
1391 * @param max_len Maximum length of returned command
1392 * @param error return location for errors
1393 * @returns #FALSE on error
1396 _dbus_command_for_pid (unsigned long pid,
1406 * Replace the DBUS_PREFIX in the given path, in-place, by the
1407 * current D-Bus installation directory. On Unix this function
1408 * does nothing, successfully.
1410 * @param path path to edit
1411 * @return #FALSE on OOM
1414 _dbus_replace_install_prefix (DBusString *path)
1417 /* leave path unchanged */
1420 DBusString runtime_prefix;
1423 if (!_dbus_string_init (&runtime_prefix))
1426 if (!_dbus_get_install_root (&runtime_prefix))
1428 _dbus_string_free (&runtime_prefix);
1432 if (_dbus_string_get_length (&runtime_prefix) == 0)
1434 /* cannot determine install root, leave path unchanged */
1435 _dbus_string_free (&runtime_prefix);
1439 if (_dbus_string_starts_with_c_str (path, DBUS_PREFIX "/"))
1441 /* Replace DBUS_PREFIX "/" with runtime_prefix.
1442 * Note unusual calling convention: source is first, then dest */
1443 if (!_dbus_string_replace_len (
1444 &runtime_prefix, 0, _dbus_string_get_length (&runtime_prefix),
1445 path, 0, strlen (DBUS_PREFIX) + 1))
1447 _dbus_string_free (&runtime_prefix);
1452 /* Somehow, in some situations, backslashes get collapsed in the string.
1453 * Since windows C library accepts both forward and backslashes as
1454 * path separators, convert all backslashes to forward slashes.
1457 for (i = 0; i < _dbus_string_get_length (path); i++)
1459 if (_dbus_string_get_byte (path, i) == '\\')
1460 _dbus_string_set_byte (path, i, '/');
1463 _dbus_string_free (&runtime_prefix);
1468 #define DBUS_STANDARD_SESSION_SERVICEDIR "/dbus-1/services"
1469 #define DBUS_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services"
1472 * Returns the standard directories for a session bus to look for
1473 * transient service activation files. On Windows, there are none.
1475 * @param dirs the directory list we are returning
1479 _dbus_set_up_transient_session_servicedirs (DBusList **dirs,
1482 /* Not an error, we just don't have transient session services on Windows */
1487 * Returns the standard directories for a session bus to look for service
1490 * On Windows this should be data directories:
1492 * %CommonProgramFiles%/dbus
1496 * relocated DBUS_DATADIR
1498 * @param dirs the directory list we are returning
1499 * @returns #FALSE on OOM
1503 _dbus_get_standard_session_servicedirs (DBusList **dirs)
1505 const char *common_progs;
1506 DBusString servicedir_path;
1508 if (!_dbus_string_init (&servicedir_path))
1513 /* On Windows CE, we adjust datadir dynamically to installation location. */
1514 const char *data_dir = _dbus_getenv ("DBUS_DATADIR");
1516 if (data_dir != NULL)
1518 if (!_dbus_string_append (&servicedir_path, data_dir))
1521 if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
1529 if (!_dbus_string_init (&p))
1532 /* DBUS_DATADIR is assumed to be absolute; the build systems should
1534 if (!_dbus_string_append (&p, DBUS_DATADIR) ||
1535 !_dbus_replace_install_prefix (&p))
1537 _dbus_string_free (&p);
1541 if (!_dbus_string_append (&servicedir_path,
1542 _dbus_string_get_const_data (&p)))
1544 _dbus_string_free (&p);
1548 _dbus_string_free (&p);
1551 if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
1555 common_progs = _dbus_getenv ("CommonProgramFiles");
1557 if (common_progs != NULL)
1559 if (!_dbus_string_append (&servicedir_path, common_progs))
1562 if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
1566 if (!_dbus_split_paths_and_append (&servicedir_path,
1567 DBUS_STANDARD_SESSION_SERVICEDIR,
1571 _dbus_string_free (&servicedir_path);
1575 _dbus_string_free (&servicedir_path);
1580 * Returns the standard directories for a system bus to look for service
1583 * On UNIX this should be the standard xdg freedesktop.org data directories:
1585 * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share}
1591 * On Windows there is no system bus and this function can return nothing.
1593 * @param dirs the directory list we are returning
1594 * @returns #FALSE on OOM
1598 _dbus_get_standard_system_servicedirs (DBusList **dirs)
1605 _dbus_get_config_file_name (DBusString *str,
1606 const char *basename)
1610 if (!_dbus_string_append (str, DBUS_DATADIR) ||
1611 !_dbus_replace_install_prefix (str))
1614 _dbus_string_init_const (&tmp, "dbus-1");
1616 if (!_dbus_concat_dir_and_file (str, &tmp))
1619 _dbus_string_init_const (&tmp, basename);
1621 if (!_dbus_concat_dir_and_file (str, &tmp))
1628 * Get the absolute path of the system.conf file
1629 * (there is no system bus on Windows so this can just
1630 * return FALSE and print a warning or something)
1632 * @param str the string to append to, which must be empty on entry
1633 * @returns #FALSE if no memory
1636 _dbus_get_system_config_file (DBusString *str)
1638 _dbus_assert (_dbus_string_get_length (str) == 0);
1640 return _dbus_get_config_file_name(str, "system.conf");
1644 * Get the absolute path of the session.conf file.
1646 * @param str the string to append to, which must be empty on entry
1647 * @returns #FALSE if no memory
1650 _dbus_get_session_config_file (DBusString *str)
1652 _dbus_assert (_dbus_string_get_length (str) == 0);
1654 return _dbus_get_config_file_name(str, "session.conf");
1657 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
1659 #define ANONYMOUS_SID "S-1-5-7"
1660 #define LOCAL_SYSTEM_SID "S-1-5-18"
1663 _dbus_test_append_different_uid (DBusString *uid)
1668 if (!_dbus_getsid (&sid, _dbus_getpid ()))
1671 if (strcmp (sid, ANONYMOUS_SID) == 0)
1672 ret = _dbus_string_append (uid, LOCAL_SYSTEM_SID);
1674 ret = _dbus_string_append (uid, ANONYMOUS_SID);