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_if_privileged (unsigned int desired,
279 fd_limit_not_supported (error);
284 _dbus_rlimit_restore_fd_limit (DBusRLimit *saved,
287 fd_limit_not_supported (error);
292 _dbus_rlimit_free (DBusRLimit *lim)
294 /* _dbus_rlimit_save_fd_limit() cannot return non-NULL on Windows
295 * so there cannot be anything to free */
296 _dbus_assert (lim == NULL);
300 _dbus_init_system_log (dbus_bool_t is_daemon)
302 /* OutputDebugStringA doesn't need any special initialization, do nothing */
306 * Log a message to the system log file (e.g. syslog on Unix).
308 * @param severity a severity value
309 * @param msg a printf-style format string
312 _dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...)
316 va_start (args, msg);
318 _dbus_system_logv (severity, msg, args);
324 * Log a message to the system log file (e.g. syslog on Unix).
326 * @param severity a severity value
327 * @param msg a printf-style format string
328 * @param args arguments for the format string
330 * If the FATAL severity is given, this function will terminate the program
331 * with an error code.
334 _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args)
342 case DBUS_SYSTEM_LOG_INFO: s = "info"; break;
343 case DBUS_SYSTEM_LOG_WARNING: s = "warning"; break;
344 case DBUS_SYSTEM_LOG_SECURITY: s = "security"; break;
345 case DBUS_SYSTEM_LOG_FATAL: s = "fatal"; break;
348 snprintf(format, sizeof(format), "%s%s", s ,msg);
349 vsnprintf(buf, sizeof(buf), format, args);
350 OutputDebugStringA(buf);
352 if (severity == DBUS_SYSTEM_LOG_FATAL)
356 /** Installs a signal handler
358 * @param sig the signal to handle
359 * @param handler the handler
362 _dbus_set_signal_handler (int sig,
363 DBusSignalHandler handler)
365 _dbus_verbose ("_dbus_set_signal_handler() has to be implemented\n");
371 * @param filename the filename to stat
372 * @param statbuf the stat info to fill in
373 * @param error return location for error
374 * @returns #FALSE if error was set
377 _dbus_stat(const DBusString *filename,
381 const char *filename_c;
382 WIN32_FILE_ATTRIBUTE_DATA wfad;
385 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
387 filename_c = _dbus_string_get_const_data (filename);
389 if (!GetFileAttributesExA (filename_c, GetFileExInfoStandard, &wfad))
391 _dbus_win_set_error_from_win_error (error, GetLastError ());
395 if (wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
396 statbuf->mode = _S_IFDIR;
398 statbuf->mode = _S_IFREG;
400 statbuf->mode |= _S_IREAD;
401 if (wfad.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
402 statbuf->mode |= _S_IWRITE;
404 lastdot = strrchr (filename_c, '.');
405 if (lastdot && stricmp (lastdot, ".exe") == 0)
406 statbuf->mode |= _S_IEXEC;
408 statbuf->mode |= (statbuf->mode & 0700) >> 3;
409 statbuf->mode |= (statbuf->mode & 0700) >> 6;
413 #ifdef ENABLE_UID_TO_SID
415 PSID owner_sid, group_sid;
416 PSECURITY_DESCRIPTOR sd;
419 rc = GetNamedSecurityInfo ((char *) filename_c, SE_FILE_OBJECT,
420 OWNER_SECURITY_INFORMATION |
421 GROUP_SECURITY_INFORMATION,
422 &owner_sid, &group_sid,
425 if (rc != ERROR_SUCCESS)
427 _dbus_win_set_error_from_win_error (error, rc);
434 statbuf->uid = _dbus_win_sid_to_uid_t (owner_sid);
435 statbuf->gid = _dbus_win_sid_to_uid_t (group_sid);
440 statbuf->uid = DBUS_UID_UNSET;
441 statbuf->gid = DBUS_GID_UNSET;
444 statbuf->size = ((dbus_int64_t) wfad.nFileSizeHigh << 32) + wfad.nFileSizeLow;
447 (((dbus_int64_t) wfad.ftLastAccessTime.dwHighDateTime << 32) +
448 wfad.ftLastAccessTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
451 (((dbus_int64_t) wfad.ftLastWriteTime.dwHighDateTime << 32) +
452 wfad.ftLastWriteTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
455 (((dbus_int64_t) wfad.ftCreationTime.dwHighDateTime << 32) +
456 wfad.ftCreationTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
462 * Internals of directory iterator
467 WIN32_FIND_DATAA fileinfo; /* from FindFirst/FindNext */
468 dbus_bool_t finished; /* true if there are no more entries */
473 * Open a directory to iterate over.
475 * @param filename the directory name
476 * @param error exception return object or #NULL
477 * @returns new iterator, or #NULL on error
480 _dbus_directory_open (const DBusString *filename,
486 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
488 if (!_dbus_string_init_from_string (&filespec, filename))
490 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
491 "Could not allocate memory for directory filename copy");
495 if (_dbus_string_ends_with_c_str (&filespec, "/") || _dbus_string_ends_with_c_str (&filespec, "\\") )
497 if (!_dbus_string_append (&filespec, "*"))
499 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
500 "Could not append filename wildcard");
504 else if (!_dbus_string_ends_with_c_str (&filespec, "*"))
506 if (!_dbus_string_append (&filespec, "\\*"))
508 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
509 "Could not append filename wildcard 2");
514 iter = dbus_new0 (DBusDirIter, 1);
517 _dbus_string_free (&filespec);
518 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
519 "Could not allocate memory for directory iterator");
523 iter->finished = FALSE;
525 iter->handle = FindFirstFileA (_dbus_string_get_const_data (&filespec), &(iter->fileinfo));
526 if (iter->handle == INVALID_HANDLE_VALUE)
528 if (GetLastError () == ERROR_NO_MORE_FILES)
529 iter->finished = TRUE;
532 char *emsg = _dbus_win_error_string (GetLastError ());
533 dbus_set_error (error, _dbus_win_error_from_last_error (),
534 "Failed to read directory \"%s\": %s",
535 _dbus_string_get_const_data (filename), emsg);
536 _dbus_win_free_error_string (emsg);
538 _dbus_string_free (&filespec);
542 _dbus_string_free (&filespec);
547 * Get next file in the directory. Will not return "." or ".." on
548 * UNIX. If an error occurs, the contents of "filename" are
549 * undefined. The error is never set if the function succeeds.
551 * @param iter the iterator
552 * @param filename string to be set to the next file in the dir
553 * @param error return location for error
554 * @returns #TRUE if filename was filled in with a new filename
557 _dbus_directory_get_next_file (DBusDirIter *iter,
558 DBusString *filename,
561 int saved_err = GetLastError();
563 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
568 if (!iter || iter->finished)
571 if (iter->offset > 0)
573 if (FindNextFileA (iter->handle, &(iter->fileinfo)) == 0)
575 if (GetLastError() == ERROR_NO_MORE_FILES)
577 SetLastError(saved_err);
582 char *emsg = _dbus_win_error_string (GetLastError ());
583 dbus_set_error (error, _dbus_win_error_from_last_error (),
584 "Failed to get next in directory: %s", emsg);
585 _dbus_win_free_error_string (emsg);
596 if (iter->fileinfo.cFileName[0] == '.' &&
597 (iter->fileinfo.cFileName[1] == '\0' ||
598 (iter->fileinfo.cFileName[1] == '.' && iter->fileinfo.cFileName[2] == '\0')))
601 _dbus_string_set_length (filename, 0);
602 if (!_dbus_string_append (filename, iter->fileinfo.cFileName))
604 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
605 "No memory to read directory entry");
613 * Closes a directory iteration.
616 _dbus_directory_close (DBusDirIter *iter)
620 FindClose(iter->handle);
624 /** @} */ /* End of DBusInternalsUtils functions */
627 * @addtogroup DBusString
632 * Get the directory name from a complete filename
633 * @param filename the filename
634 * @param dirname string to append directory name to
635 * @returns #FALSE if no memory
638 _dbus_string_get_dirname(const DBusString *filename,
643 _dbus_assert (filename != dirname);
644 _dbus_assert (filename != NULL);
645 _dbus_assert (dirname != NULL);
647 /* Ignore any separators on the end */
648 sep = _dbus_string_get_length (filename);
650 return _dbus_string_append (dirname, "."); /* empty string passed in */
653 (_dbus_string_get_byte (filename, sep - 1) == '/' ||
654 _dbus_string_get_byte (filename, sep - 1) == '\\'))
657 _dbus_assert (sep >= 0);
661 _dbus_string_get_byte (filename, 1) == ':' &&
662 isalpha (_dbus_string_get_byte (filename, 0))))
663 return _dbus_string_copy_len (filename, 0, sep + 1,
664 dirname, _dbus_string_get_length (dirname));
668 _dbus_string_find_byte_backward (filename, sep, '/', &sep1);
669 _dbus_string_find_byte_backward (filename, sep, '\\', &sep2);
671 sep = MAX (sep1, sep2);
674 return _dbus_string_append (dirname, ".");
677 (_dbus_string_get_byte (filename, sep - 1) == '/' ||
678 _dbus_string_get_byte (filename, sep - 1) == '\\'))
681 _dbus_assert (sep >= 0);
685 _dbus_string_get_byte (filename, 1) == ':' &&
686 isalpha (_dbus_string_get_byte (filename, 0))))
688 (_dbus_string_get_byte (filename, sep) == '/' ||
689 _dbus_string_get_byte (filename, sep) == '\\'))
690 return _dbus_string_copy_len (filename, 0, sep + 1,
691 dirname, _dbus_string_get_length (dirname));
693 return _dbus_string_copy_len (filename, 0, sep - 0,
694 dirname, _dbus_string_get_length (dirname));
699 * Checks to see if the UNIX user ID matches the UID of
700 * the process. Should always return #FALSE on Windows.
702 * @param uid the UNIX user ID
703 * @returns #TRUE if this uid owns the process.
706 _dbus_unix_user_is_process_owner (dbus_uid_t uid)
711 dbus_bool_t _dbus_windows_user_is_process_owner (const char *windows_sid)
716 /*=====================================================================
717 unix emulation functions - should be removed sometime in the future
718 =====================================================================*/
721 * Checks to see if the UNIX user ID is at the console.
722 * Should always fail on Windows (set the error to
723 * #DBUS_ERROR_NOT_SUPPORTED).
725 * @param uid UID of person to check
726 * @param error return location for errors
727 * @returns #TRUE if the UID is the same as the console user and there are no errors
730 _dbus_unix_user_is_at_console (dbus_uid_t uid,
733 dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
734 "UNIX user IDs not supported on Windows\n");
740 * Parse a UNIX group from the bus config file. On Windows, this should
741 * simply always fail (just return #FALSE).
743 * @param groupname the groupname text
744 * @param gid_p place to return the gid
745 * @returns #TRUE on success
748 _dbus_parse_unix_group_from_config (const DBusString *groupname,
755 * Parse a UNIX user from the bus config file. On Windows, this should
756 * simply always fail (just return #FALSE).
758 * @param username the username text
759 * @param uid_p place to return the uid
760 * @returns #TRUE on success
763 _dbus_parse_unix_user_from_config (const DBusString *username,
771 * Gets all groups corresponding to the given UNIX user ID. On UNIX,
772 * just calls _dbus_groups_from_uid(). On Windows, should always
773 * fail since we don't know any UNIX groups.
776 * @param group_ids return location for array of group IDs
777 * @param n_group_ids return location for length of returned array
778 * @returns #TRUE if the UID existed and we got some credentials
781 _dbus_unix_groups_from_uid (dbus_uid_t uid,
782 dbus_gid_t **group_ids,
790 /** @} */ /* DBusString stuff */
792 /************************************************************************
796 ************************************************************************/
802 /* lan manager error codes */
804 _dbus_lm_strerror(int error_number)
811 switch (error_number)
813 case NERR_NetNotStarted:
814 return "The workstation driver is not installed.";
815 case NERR_UnknownServer:
816 return "The server could not be located.";
818 return "An internal error occurred. The network cannot access a shared memory segment.";
819 case NERR_NoNetworkResource:
820 return "A network resource shortage occurred.";
821 case NERR_RemoteOnly:
822 return "This operation is not supported on workstations.";
823 case NERR_DevNotRedirected:
824 return "The device is not connected.";
825 case NERR_ServerNotStarted:
826 return "The Server service is not started.";
827 case NERR_ItemNotFound:
828 return "The queue is empty.";
829 case NERR_UnknownDevDir:
830 return "The device or directory does not exist.";
831 case NERR_RedirectedPath:
832 return "The operation is invalid on a redirected resource.";
833 case NERR_DuplicateShare:
834 return "The name has already been shared.";
836 return "The server is currently out of the requested resource.";
837 case NERR_TooManyItems:
838 return "Requested addition of items exceeds the maximum allowed.";
839 case NERR_InvalidMaxUsers:
840 return "The Peer service supports only two simultaneous users.";
841 case NERR_BufTooSmall:
842 return "The API return buffer is too small.";
844 return "A remote API error occurred.";
845 case NERR_LanmanIniError:
846 return "An error occurred when opening or reading the configuration file.";
847 case NERR_NetworkError:
848 return "A general network error occurred.";
849 case NERR_WkstaInconsistentState:
850 return "The Workstation service is in an inconsistent state. Restart the computer before restarting the Workstation service.";
851 case NERR_WkstaNotStarted:
852 return "The Workstation service has not been started.";
853 case NERR_BrowserNotStarted:
854 return "The requested information is not available.";
855 case NERR_InternalError:
856 return "An internal error occurred.";
857 case NERR_BadTransactConfig:
858 return "The server is not configured for transactions.";
859 case NERR_InvalidAPI:
860 return "The requested API is not supported on the remote server.";
861 case NERR_BadEventName:
862 return "The event name is invalid.";
863 case NERR_DupNameReboot:
864 return "The computer name already exists on the network. Change it and restart the computer.";
865 case NERR_CfgCompNotFound:
866 return "The specified component could not be found in the configuration information.";
867 case NERR_CfgParamNotFound:
868 return "The specified parameter could not be found in the configuration information.";
869 case NERR_LineTooLong:
870 return "A line in the configuration file is too long.";
872 return "The printer does not exist.";
873 case NERR_JobNotFound:
874 return "The print job does not exist.";
875 case NERR_DestNotFound:
876 return "The printer destination cannot be found.";
877 case NERR_DestExists:
878 return "The printer destination already exists.";
880 return "The printer queue already exists.";
882 return "No more printers can be added.";
884 return "No more print jobs can be added.";
885 case NERR_DestNoRoom:
886 return "No more printer destinations can be added.";
888 return "This printer destination is idle and cannot accept control operations.";
889 case NERR_DestInvalidOp:
890 return "This printer destination request contains an invalid control function.";
891 case NERR_ProcNoRespond:
892 return "The print processor is not responding.";
893 case NERR_SpoolerNotLoaded:
894 return "The spooler is not running.";
895 case NERR_DestInvalidState:
896 return "This operation cannot be performed on the print destination in its current state.";
897 case NERR_QInvalidState:
898 return "This operation cannot be performed on the printer queue in its current state.";
899 case NERR_JobInvalidState:
900 return "This operation cannot be performed on the print job in its current state.";
901 case NERR_SpoolNoMemory:
902 return "A spooler memory allocation failure occurred.";
903 case NERR_DriverNotFound:
904 return "The device driver does not exist.";
905 case NERR_DataTypeInvalid:
906 return "The data type is not supported by the print processor.";
907 case NERR_ProcNotFound:
908 return "The print processor is not installed.";
909 case NERR_ServiceTableLocked:
910 return "The service database is locked.";
911 case NERR_ServiceTableFull:
912 return "The service table is full.";
913 case NERR_ServiceInstalled:
914 return "The requested service has already been started.";
915 case NERR_ServiceEntryLocked:
916 return "The service does not respond to control actions.";
917 case NERR_ServiceNotInstalled:
918 return "The service has not been started.";
919 case NERR_BadServiceName:
920 return "The service name is invalid.";
921 case NERR_ServiceCtlTimeout:
922 return "The service is not responding to the control function.";
923 case NERR_ServiceCtlBusy:
924 return "The service control is busy.";
925 case NERR_BadServiceProgName:
926 return "The configuration file contains an invalid service program name.";
927 case NERR_ServiceNotCtrl:
928 return "The service could not be controlled in its present state.";
929 case NERR_ServiceKillProc:
930 return "The service ended abnormally.";
931 case NERR_ServiceCtlNotValid:
932 return "The requested pause or stop is not valid for this service.";
933 case NERR_NotInDispatchTbl:
934 return "The service control dispatcher could not find the service name in the dispatch table.";
935 case NERR_BadControlRecv:
936 return "The service control dispatcher pipe read failed.";
937 case NERR_ServiceNotStarting:
938 return "A thread for the new service could not be created.";
939 case NERR_AlreadyLoggedOn:
940 return "This workstation is already logged on to the local-area network.";
941 case NERR_NotLoggedOn:
942 return "The workstation is not logged on to the local-area network.";
943 case NERR_BadUsername:
944 return "The user name or group name parameter is invalid.";
945 case NERR_BadPassword:
946 return "The password parameter is invalid.";
947 case NERR_UnableToAddName_W:
948 return "@W The logon processor did not add the message alias.";
949 case NERR_UnableToAddName_F:
950 return "The logon processor did not add the message alias.";
951 case NERR_UnableToDelName_W:
952 return "@W The logoff processor did not delete the message alias.";
953 case NERR_UnableToDelName_F:
954 return "The logoff processor did not delete the message alias.";
955 case NERR_LogonsPaused:
956 return "Network logons are paused.";
957 case NERR_LogonServerConflict:
958 return "A centralized logon-server conflict occurred.";
959 case NERR_LogonNoUserPath:
960 return "The server is configured without a valid user path.";
961 case NERR_LogonScriptError:
962 return "An error occurred while loading or running the logon script.";
963 case NERR_StandaloneLogon:
964 return "The logon server was not specified. Your computer will be logged on as STANDALONE.";
965 case NERR_LogonServerNotFound:
966 return "The logon server could not be found.";
967 case NERR_LogonDomainExists:
968 return "There is already a logon domain for this computer.";
969 case NERR_NonValidatedLogon:
970 return "The logon server could not validate the logon.";
971 case NERR_ACFNotFound:
972 return "The security database could not be found.";
973 case NERR_GroupNotFound:
974 return "The group name could not be found.";
975 case NERR_UserNotFound:
976 return "The user name could not be found.";
977 case NERR_ResourceNotFound:
978 return "The resource name could not be found.";
979 case NERR_GroupExists:
980 return "The group already exists.";
981 case NERR_UserExists:
982 return "The user account already exists.";
983 case NERR_ResourceExists:
984 return "The resource permission list already exists.";
985 case NERR_NotPrimary:
986 return "This operation is only allowed on the primary domain controller of the domain.";
987 case NERR_ACFNotLoaded:
988 return "The security database has not been started.";
990 return "There are too many names in the user accounts database.";
991 case NERR_ACFFileIOFail:
992 return "A disk I/O failure occurred.";
993 case NERR_ACFTooManyLists:
994 return "The limit of 64 entries per resource was exceeded.";
996 return "Deleting a user with a session is not allowed.";
997 case NERR_ACFNoParent:
998 return "The parent directory could not be located.";
999 case NERR_CanNotGrowSegment:
1000 return "Unable to add to the security database session cache segment.";
1001 case NERR_SpeGroupOp:
1002 return "This operation is not allowed on this special group.";
1003 case NERR_NotInCache:
1004 return "This user is not cached in user accounts database session cache.";
1005 case NERR_UserInGroup:
1006 return "The user already belongs to this group.";
1007 case NERR_UserNotInGroup:
1008 return "The user does not belong to this group.";
1009 case NERR_AccountUndefined:
1010 return "This user account is undefined.";
1011 case NERR_AccountExpired:
1012 return "This user account has expired.";
1013 case NERR_InvalidWorkstation:
1014 return "The user is not allowed to log on from this workstation.";
1015 case NERR_InvalidLogonHours:
1016 return "The user is not allowed to log on at this time.";
1017 case NERR_PasswordExpired:
1018 return "The password of this user has expired.";
1019 case NERR_PasswordCantChange:
1020 return "The password of this user cannot change.";
1021 case NERR_PasswordHistConflict:
1022 return "This password cannot be used now.";
1023 case NERR_PasswordTooShort:
1024 return "The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements.";
1025 case NERR_PasswordTooRecent:
1026 return "The password of this user is too recent to change.";
1027 case NERR_InvalidDatabase:
1028 return "The security database is corrupted.";
1029 case NERR_DatabaseUpToDate:
1030 return "No updates are necessary to this replicant network/local security database.";
1031 case NERR_SyncRequired:
1032 return "This replicant database is outdated; synchronization is required.";
1033 case NERR_UseNotFound:
1034 return "The network connection could not be found.";
1035 case NERR_BadAsgType:
1036 return "This asg_type is invalid.";
1037 case NERR_DeviceIsShared:
1038 return "This device is currently being shared.";
1039 case NERR_NoComputerName:
1040 return "The computer name could not be added as a message alias. The name may already exist on the network.";
1041 case NERR_MsgAlreadyStarted:
1042 return "The Messenger service is already started.";
1043 case NERR_MsgInitFailed:
1044 return "The Messenger service failed to start.";
1045 case NERR_NameNotFound:
1046 return "The message alias could not be found on the network.";
1047 case NERR_AlreadyForwarded:
1048 return "This message alias has already been forwarded.";
1049 case NERR_AddForwarded:
1050 return "This message alias has been added but is still forwarded.";
1051 case NERR_AlreadyExists:
1052 return "This message alias already exists locally.";
1053 case NERR_TooManyNames:
1054 return "The maximum number of added message aliases has been exceeded.";
1055 case NERR_DelComputerName:
1056 return "The computer name could not be deleted.";
1057 case NERR_LocalForward:
1058 return "Messages cannot be forwarded back to the same workstation.";
1059 case NERR_GrpMsgProcessor:
1060 return "An error occurred in the domain message processor.";
1061 case NERR_PausedRemote:
1062 return "The message was sent, but the recipient has paused the Messenger service.";
1063 case NERR_BadReceive:
1064 return "The message was sent but not received.";
1065 case NERR_NameInUse:
1066 return "The message alias is currently in use. Try again later.";
1067 case NERR_MsgNotStarted:
1068 return "The Messenger service has not been started.";
1069 case NERR_NotLocalName:
1070 return "The name is not on the local computer.";
1071 case NERR_NoForwardName:
1072 return "The forwarded message alias could not be found on the network.";
1073 case NERR_RemoteFull:
1074 return "The message alias table on the remote station is full.";
1075 case NERR_NameNotForwarded:
1076 return "Messages for this alias are not currently being forwarded.";
1077 case NERR_TruncatedBroadcast:
1078 return "The broadcast message was truncated.";
1079 case NERR_InvalidDevice:
1080 return "This is an invalid device name.";
1081 case NERR_WriteFault:
1082 return "A write fault occurred.";
1083 case NERR_DuplicateName:
1084 return "A duplicate message alias exists on the network.";
1085 case NERR_DeleteLater:
1086 return "@W This message alias will be deleted later.";
1087 case NERR_IncompleteDel:
1088 return "The message alias was not successfully deleted from all networks.";
1089 case NERR_MultipleNets:
1090 return "This operation is not supported on computers with multiple networks.";
1091 case NERR_NetNameNotFound:
1092 return "This shared resource does not exist.";
1093 case NERR_DeviceNotShared:
1094 return "This device is not shared.";
1095 case NERR_ClientNameNotFound:
1096 return "A session does not exist with that computer name.";
1097 case NERR_FileIdNotFound:
1098 return "There is not an open file with that identification number.";
1099 case NERR_ExecFailure:
1100 return "A failure occurred when executing a remote administration command.";
1102 return "A failure occurred when opening a remote temporary file.";
1103 case NERR_TooMuchData:
1104 return "The data returned from a remote administration command has been truncated to 64K.";
1105 case NERR_DeviceShareConflict:
1106 return "This device cannot be shared as both a spooled and a non-spooled resource.";
1107 case NERR_BrowserTableIncomplete:
1108 return "The information in the list of servers may be incorrect.";
1109 case NERR_NotLocalDomain:
1110 return "The computer is not active in this domain.";
1111 #ifdef NERR_IsDfsShare
1113 case NERR_IsDfsShare:
1114 return "The share must be removed from the Distributed File System before it can be deleted.";
1117 case NERR_DevInvalidOpCode:
1118 return "The operation is invalid for this device.";
1119 case NERR_DevNotFound:
1120 return "This device cannot be shared.";
1121 case NERR_DevNotOpen:
1122 return "This device was not open.";
1123 case NERR_BadQueueDevString:
1124 return "This device name list is invalid.";
1125 case NERR_BadQueuePriority:
1126 return "The queue priority is invalid.";
1127 case NERR_NoCommDevs:
1128 return "There are no shared communication devices.";
1129 case NERR_QueueNotFound:
1130 return "The queue you specified does not exist.";
1131 case NERR_BadDevString:
1132 return "This list of devices is invalid.";
1134 return "The requested device is invalid.";
1135 case NERR_InUseBySpooler:
1136 return "This device is already in use by the spooler.";
1137 case NERR_CommDevInUse:
1138 return "This device is already in use as a communication device.";
1139 case NERR_InvalidComputer:
1140 return "This computer name is invalid.";
1141 case NERR_MaxLenExceeded:
1142 return "The string and prefix specified are too long.";
1143 case NERR_BadComponent:
1144 return "This path component is invalid.";
1146 return "Could not determine the type of input.";
1147 case NERR_TooManyEntries:
1148 return "The buffer for types is not big enough.";
1149 case NERR_ProfileFileTooBig:
1150 return "Profile files cannot exceed 64K.";
1151 case NERR_ProfileOffset:
1152 return "The start offset is out of range.";
1153 case NERR_ProfileCleanup:
1154 return "The system cannot delete current connections to network resources.";
1155 case NERR_ProfileUnknownCmd:
1156 return "The system was unable to parse the command line in this file.";
1157 case NERR_ProfileLoadErr:
1158 return "An error occurred while loading the profile file.";
1159 case NERR_ProfileSaveErr:
1160 return "@W Errors occurred while saving the profile file. The profile was partially saved.";
1161 case NERR_LogOverflow:
1162 return "Log file %1 is full.";
1163 case NERR_LogFileChanged:
1164 return "This log file has changed between reads.";
1165 case NERR_LogFileCorrupt:
1166 return "Log file %1 is corrupt.";
1167 case NERR_SourceIsDir:
1168 return "The source path cannot be a directory.";
1169 case NERR_BadSource:
1170 return "The source path is illegal.";
1172 return "The destination path is illegal.";
1173 case NERR_DifferentServers:
1174 return "The source and destination paths are on different servers.";
1175 case NERR_RunSrvPaused:
1176 return "The Run server you requested is paused.";
1177 case NERR_ErrCommRunSrv:
1178 return "An error occurred when communicating with a Run server.";
1179 case NERR_ErrorExecingGhost:
1180 return "An error occurred when starting a background process.";
1181 case NERR_ShareNotFound:
1182 return "The shared resource you are connected to could not be found.";
1183 case NERR_InvalidLana:
1184 return "The LAN adapter number is invalid.";
1185 case NERR_OpenFiles:
1186 return "There are open files on the connection.";
1187 case NERR_ActiveConns:
1188 return "Active connections still exist.";
1189 case NERR_BadPasswordCore:
1190 return "This share name or password is invalid.";
1192 return "The device is being accessed by an active process.";
1193 case NERR_LocalDrive:
1194 return "The drive letter is in use locally.";
1195 case NERR_AlertExists:
1196 return "The specified client is already registered for the specified event.";
1197 case NERR_TooManyAlerts:
1198 return "The alert table is full.";
1199 case NERR_NoSuchAlert:
1200 return "An invalid or nonexistent alert name was raised.";
1201 case NERR_BadRecipient:
1202 return "The alert recipient is invalid.";
1203 case NERR_AcctLimitExceeded:
1204 return "A user's session with this server has been deleted.";
1205 case NERR_InvalidLogSeek:
1206 return "The log file does not contain the requested record number.";
1207 case NERR_BadUasConfig:
1208 return "The user accounts database is not configured correctly.";
1209 case NERR_InvalidUASOp:
1210 return "This operation is not permitted when the Netlogon service is running.";
1211 case NERR_LastAdmin:
1212 return "This operation is not allowed on the last administrative account.";
1213 case NERR_DCNotFound:
1214 return "Could not find domain controller for this domain.";
1215 case NERR_LogonTrackingError:
1216 return "Could not set logon information for this user.";
1217 case NERR_NetlogonNotStarted:
1218 return "The Netlogon service has not been started.";
1219 case NERR_CanNotGrowUASFile:
1220 return "Unable to add to the user accounts database.";
1221 case NERR_TimeDiffAtDC:
1222 return "This server's clock is not synchronized with the primary domain controller's clock.";
1223 case NERR_PasswordMismatch:
1224 return "A password mismatch has been detected.";
1225 case NERR_NoSuchServer:
1226 return "The server identification does not specify a valid server.";
1227 case NERR_NoSuchSession:
1228 return "The session identification does not specify a valid session.";
1229 case NERR_NoSuchConnection:
1230 return "The connection identification does not specify a valid connection.";
1231 case NERR_TooManyServers:
1232 return "There is no space for another entry in the table of available servers.";
1233 case NERR_TooManySessions:
1234 return "The server has reached the maximum number of sessions it supports.";
1235 case NERR_TooManyConnections:
1236 return "The server has reached the maximum number of connections it supports.";
1237 case NERR_TooManyFiles:
1238 return "The server cannot open more files because it has reached its maximum number.";
1239 case NERR_NoAlternateServers:
1240 return "There are no alternate servers registered on this server.";
1241 case NERR_TryDownLevel:
1242 return "Try down-level (remote admin protocol) version of API instead.";
1243 case NERR_UPSDriverNotStarted:
1244 return "The UPS driver could not be accessed by the UPS service.";
1245 case NERR_UPSInvalidConfig:
1246 return "The UPS service is not configured correctly.";
1247 case NERR_UPSInvalidCommPort:
1248 return "The UPS service could not access the specified Comm Port.";
1249 case NERR_UPSSignalAsserted:
1250 return "The UPS indicated a line fail or low battery situation. Service not started.";
1251 case NERR_UPSShutdownFailed:
1252 return "The UPS service failed to perform a system shut down.";
1253 case NERR_BadDosRetCode:
1254 return "The program below returned an MS-DOS error code:";
1255 case NERR_ProgNeedsExtraMem:
1256 return "The program below needs more memory:";
1257 case NERR_BadDosFunction:
1258 return "The program below called an unsupported MS-DOS function:";
1259 case NERR_RemoteBootFailed:
1260 return "The workstation failed to boot.";
1261 case NERR_BadFileCheckSum:
1262 return "The file below is corrupt.";
1263 case NERR_NoRplBootSystem:
1264 return "No loader is specified in the boot-block definition file.";
1265 case NERR_RplLoadrNetBiosErr:
1266 return "NetBIOS returned an error: The NCB and SMB are dumped above.";
1267 case NERR_RplLoadrDiskErr:
1268 return "A disk I/O error occurred.";
1269 case NERR_ImageParamErr:
1270 return "Image parameter substitution failed.";
1271 case NERR_TooManyImageParams:
1272 return "Too many image parameters cross disk sector boundaries.";
1273 case NERR_NonDosFloppyUsed:
1274 return "The image was not generated from an MS-DOS diskette formatted with /S.";
1275 case NERR_RplBootRestart:
1276 return "Remote boot will be restarted later.";
1277 case NERR_RplSrvrCallFailed:
1278 return "The call to the Remoteboot server failed.";
1279 case NERR_CantConnectRplSrvr:
1280 return "Cannot connect to the Remoteboot server.";
1281 case NERR_CantOpenImageFile:
1282 return "Cannot open image file on the Remoteboot server.";
1283 case NERR_CallingRplSrvr:
1284 return "Connecting to the Remoteboot server...";
1285 case NERR_StartingRplBoot:
1286 return "Connecting to the Remoteboot server...";
1287 case NERR_RplBootServiceTerm:
1288 return "Remote boot service was stopped; check the error log for the cause of the problem.";
1289 case NERR_RplBootStartFailed:
1290 return "Remote boot startup failed; check the error log for the cause of the problem.";
1291 case NERR_RPL_CONNECTED:
1292 return "A second connection to a Remoteboot resource is not allowed.";
1293 case NERR_BrowserConfiguredToNotRun:
1294 return "The browser service was configured with MaintainServerList=No.";
1295 case NERR_RplNoAdaptersStarted:
1296 return "Service failed to start since none of the network adapters started with this service.";
1297 case NERR_RplBadRegistry:
1298 return "Service failed to start due to bad startup information in the registry.";
1299 case NERR_RplBadDatabase:
1300 return "Service failed to start because its database is absent or corrupt.";
1301 case NERR_RplRplfilesShare:
1302 return "Service failed to start because RPLFILES share is absent.";
1303 case NERR_RplNotRplServer:
1304 return "Service failed to start because RPLUSER group is absent.";
1305 case NERR_RplCannotEnum:
1306 return "Cannot enumerate service records.";
1307 case NERR_RplWkstaInfoCorrupted:
1308 return "Workstation record information has been corrupted.";
1309 case NERR_RplWkstaNotFound:
1310 return "Workstation record was not found.";
1311 case NERR_RplWkstaNameUnavailable:
1312 return "Workstation name is in use by some other workstation.";
1313 case NERR_RplProfileInfoCorrupted:
1314 return "Profile record information has been corrupted.";
1315 case NERR_RplProfileNotFound:
1316 return "Profile record was not found.";
1317 case NERR_RplProfileNameUnavailable:
1318 return "Profile name is in use by some other profile.";
1319 case NERR_RplProfileNotEmpty:
1320 return "There are workstations using this profile.";
1321 case NERR_RplConfigInfoCorrupted:
1322 return "Configuration record information has been corrupted.";
1323 case NERR_RplConfigNotFound:
1324 return "Configuration record was not found.";
1325 case NERR_RplAdapterInfoCorrupted:
1326 return "Adapter ID record information has been corrupted.";
1327 case NERR_RplInternal:
1328 return "An internal service error has occurred.";
1329 case NERR_RplVendorInfoCorrupted:
1330 return "Vendor ID record information has been corrupted.";
1331 case NERR_RplBootInfoCorrupted:
1332 return "Boot block record information has been corrupted.";
1333 case NERR_RplWkstaNeedsUserAcct:
1334 return "The user account for this workstation record is missing.";
1335 case NERR_RplNeedsRPLUSERAcct:
1336 return "The RPLUSER local group could not be found.";
1337 case NERR_RplBootNotFound:
1338 return "Boot block record was not found.";
1339 case NERR_RplIncompatibleProfile:
1340 return "Chosen profile is incompatible with this workstation.";
1341 case NERR_RplAdapterNameUnavailable:
1342 return "Chosen network adapter ID is in use by some other workstation.";
1343 case NERR_RplConfigNotEmpty:
1344 return "There are profiles using this configuration.";
1345 case NERR_RplBootInUse:
1346 return "There are workstations, profiles, or configurations using this boot block.";
1347 case NERR_RplBackupDatabase:
1348 return "Service failed to backup Remoteboot database.";
1349 case NERR_RplAdapterNotFound:
1350 return "Adapter record was not found.";
1351 case NERR_RplVendorNotFound:
1352 return "Vendor record was not found.";
1353 case NERR_RplVendorNameUnavailable:
1354 return "Vendor name is in use by some other vendor record.";
1355 case NERR_RplBootNameUnavailable:
1356 return "(boot name, vendor ID) is in use by some other boot block record.";
1357 case NERR_RplConfigNameUnavailable:
1358 return "Configuration name is in use by some other configuration.";
1359 case NERR_DfsInternalCorruption:
1360 return "The internal database maintained by the Dfs service is corrupt.";
1361 case NERR_DfsVolumeDataCorrupt:
1362 return "One of the records in the internal Dfs database is corrupt.";
1363 case NERR_DfsNoSuchVolume:
1364 return "There is no DFS name whose entry path matches the input Entry Path.";
1365 case NERR_DfsVolumeAlreadyExists:
1366 return "A root or link with the given name already exists.";
1367 case NERR_DfsAlreadyShared:
1368 return "The server share specified is already shared in the Dfs.";
1369 case NERR_DfsNoSuchShare:
1370 return "The indicated server share does not support the indicated DFS namespace.";
1371 case NERR_DfsNotALeafVolume:
1372 return "The operation is not valid on this portion of the namespace.";
1373 case NERR_DfsLeafVolume:
1374 return "The operation is not valid on this portion of the namespace.";
1375 case NERR_DfsVolumeHasMultipleServers:
1376 return "The operation is ambiguous because the link has multiple servers.";
1377 case NERR_DfsCantCreateJunctionPoint:
1378 return "Unable to create a link.";
1379 case NERR_DfsServerNotDfsAware:
1380 return "The server is not Dfs Aware.";
1381 case NERR_DfsBadRenamePath:
1382 return "The specified rename target path is invalid.";
1383 case NERR_DfsVolumeIsOffline:
1384 return "The specified DFS link is offline.";
1385 case NERR_DfsNoSuchServer:
1386 return "The specified server is not a server for this link.";
1387 case NERR_DfsCyclicalName:
1388 return "A cycle in the Dfs name was detected.";
1389 case NERR_DfsNotSupportedInServerDfs:
1390 return "The operation is not supported on a server-based Dfs.";
1391 case NERR_DfsDuplicateService:
1392 return "This link is already supported by the specified server-share.";
1393 case NERR_DfsCantRemoveLastServerShare:
1394 return "Can't remove the last server-share supporting this root or link.";
1395 case NERR_DfsVolumeIsInterDfs:
1396 return "The operation is not supported for an Inter-DFS link.";
1397 case NERR_DfsInconsistent:
1398 return "The internal state of the Dfs Service has become inconsistent.";
1399 case NERR_DfsServerUpgraded:
1400 return "The Dfs Service has been installed on the specified server.";
1401 case NERR_DfsDataIsIdentical:
1402 return "The Dfs data being reconciled is identical.";
1403 case NERR_DfsCantRemoveDfsRoot:
1404 return "The DFS root cannot be deleted. Uninstall DFS if required.";
1405 case NERR_DfsChildOrParentInDfs:
1406 return "A child or parent directory of the share is already in a Dfs.";
1407 case NERR_DfsInternalError:
1408 return "Dfs internal error.";
1409 /* the following are not defined in mingw */
1412 case NERR_SetupAlreadyJoined:
1413 return "This machine is already joined to a domain.";
1414 case NERR_SetupNotJoined:
1415 return "This machine is not currently joined to a domain.";
1416 case NERR_SetupDomainController:
1417 return "This machine is a domain controller and cannot be unjoined from a domain.";
1418 case NERR_DefaultJoinRequired:
1419 return "The destination domain controller does not support creating machine accounts in OUs.";
1420 case NERR_InvalidWorkgroupName:
1421 return "The specified workgroup name is invalid.";
1422 case NERR_NameUsesIncompatibleCodePage:
1423 return "The specified computer name is incompatible with the default language used on the domain controller.";
1424 case NERR_ComputerAccountNotFound:
1425 return "The specified computer account could not be found.";
1426 case NERR_PersonalSku:
1427 return "This version of Windows cannot be joined to a domain.";
1428 case NERR_PasswordMustChange:
1429 return "The password must change at the next logon.";
1430 case NERR_AccountLockedOut:
1431 return "The account is locked out.";
1432 case NERR_PasswordTooLong:
1433 return "The password is too long.";
1434 case NERR_PasswordNotComplexEnough:
1435 return "The password does not meet the complexity policy.";
1436 case NERR_PasswordFilterError:
1437 return "The password does not meet the requirements of the password filter DLLs.";
1441 msg = strerror (error_number);
1450 * Get a printable string describing the command used to execute
1451 * the process with pid. This string should only be used for
1452 * informative purposes such as logging; it may not be trusted.
1454 * The command is guaranteed to be printable ASCII and no longer
1457 * @param pid Process id
1458 * @param str Append command to this string
1459 * @param max_len Maximum length of returned command
1460 * @param error return location for errors
1461 * @returns #FALSE on error
1464 _dbus_command_for_pid (unsigned long pid,
1474 * Replace the DBUS_PREFIX in the given path, in-place, by the
1475 * current D-Bus installation directory. On Unix this function
1476 * does nothing, successfully.
1478 * @param path path to edit
1479 * @return #FALSE on OOM
1482 _dbus_replace_install_prefix (DBusString *path)
1485 /* leave path unchanged */
1488 DBusString runtime_prefix;
1491 if (!_dbus_string_init (&runtime_prefix))
1494 if (!_dbus_get_install_root (&runtime_prefix))
1496 _dbus_string_free (&runtime_prefix);
1500 if (_dbus_string_get_length (&runtime_prefix) == 0)
1502 /* cannot determine install root, leave path unchanged */
1503 _dbus_string_free (&runtime_prefix);
1507 if (_dbus_string_starts_with_c_str (path, DBUS_PREFIX "/"))
1509 /* Replace DBUS_PREFIX "/" with runtime_prefix.
1510 * Note unusual calling convention: source is first, then dest */
1511 if (!_dbus_string_replace_len (
1512 &runtime_prefix, 0, _dbus_string_get_length (&runtime_prefix),
1513 path, 0, strlen (DBUS_PREFIX) + 1))
1515 _dbus_string_free (&runtime_prefix);
1520 /* Somehow, in some situations, backslashes get collapsed in the string.
1521 * Since windows C library accepts both forward and backslashes as
1522 * path separators, convert all backslashes to forward slashes.
1525 for (i = 0; i < _dbus_string_get_length (path); i++)
1527 if (_dbus_string_get_byte (path, i) == '\\')
1528 _dbus_string_set_byte (path, i, '/');
1531 _dbus_string_free (&runtime_prefix);
1536 #define DBUS_STANDARD_SESSION_SERVICEDIR "/dbus-1/services"
1537 #define DBUS_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services"
1540 * Returns the standard directories for a session bus to look for service
1543 * On Windows this should be data directories:
1545 * %CommonProgramFiles%/dbus
1549 * relocated DBUS_DATADIR
1551 * @param dirs the directory list we are returning
1552 * @returns #FALSE on OOM
1556 _dbus_get_standard_session_servicedirs (DBusList **dirs)
1558 const char *common_progs;
1559 DBusString servicedir_path;
1561 if (!_dbus_string_init (&servicedir_path))
1566 /* On Windows CE, we adjust datadir dynamically to installation location. */
1567 const char *data_dir = _dbus_getenv ("DBUS_DATADIR");
1569 if (data_dir != NULL)
1571 if (!_dbus_string_append (&servicedir_path, data_dir))
1574 if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
1582 if (!_dbus_string_init (&p))
1585 /* DBUS_DATADIR is assumed to be absolute; the build systems should
1587 if (!_dbus_string_append (&p, DBUS_DATADIR) ||
1588 !_dbus_replace_install_prefix (&p))
1590 _dbus_string_free (&p);
1594 if (!_dbus_string_append (&servicedir_path,
1595 _dbus_string_get_const_data (&p)))
1597 _dbus_string_free (&p);
1601 _dbus_string_free (&p);
1604 if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
1608 common_progs = _dbus_getenv ("CommonProgramFiles");
1610 if (common_progs != NULL)
1612 if (!_dbus_string_append (&servicedir_path, common_progs))
1615 if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
1619 if (!_dbus_split_paths_and_append (&servicedir_path,
1620 DBUS_STANDARD_SESSION_SERVICEDIR,
1624 _dbus_string_free (&servicedir_path);
1628 _dbus_string_free (&servicedir_path);
1633 * Returns the standard directories for a system bus to look for service
1636 * On UNIX this should be the standard xdg freedesktop.org data directories:
1638 * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share}
1644 * On Windows there is no system bus and this function can return nothing.
1646 * @param dirs the directory list we are returning
1647 * @returns #FALSE on OOM
1651 _dbus_get_standard_system_servicedirs (DBusList **dirs)
1658 _dbus_get_config_file_name (DBusString *str,
1659 const char *basename)
1663 if (!_dbus_string_append (str, DBUS_DATADIR) ||
1664 !_dbus_replace_install_prefix (str))
1667 _dbus_string_init_const (&tmp, "dbus-1");
1669 if (!_dbus_concat_dir_and_file (str, &tmp))
1672 _dbus_string_init_const (&tmp, basename);
1674 if (!_dbus_concat_dir_and_file (str, &tmp))
1681 * Get the absolute path of the system.conf file
1682 * (there is no system bus on Windows so this can just
1683 * return FALSE and print a warning or something)
1685 * @param str the string to append to, which must be empty on entry
1686 * @returns #FALSE if no memory
1689 _dbus_get_system_config_file (DBusString *str)
1691 _dbus_assert (_dbus_string_get_length (str) == 0);
1693 return _dbus_get_config_file_name(str, "system.conf");
1697 * Get the absolute path of the session.conf file.
1699 * @param str the string to append to, which must be empty on entry
1700 * @returns #FALSE if no memory
1703 _dbus_get_session_config_file (DBusString *str)
1705 _dbus_assert (_dbus_string_get_length (str) == 0);
1707 return _dbus_get_config_file_name(str, "session.conf");