D-Bus 1.15.8
dbus-sysdeps-util-win.c
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
3 *
4 * Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc.
5 * Copyright (C) 2003 CodeFactory AB
6 *
7 * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
8 *
9 * Licensed under the Academic Free License version 2.1
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 *
25 */
26
27#include <config.h>
28
29#define STRSAFE_NO_DEPRECATE
30
31#include "dbus-sysdeps.h"
32#include "dbus-internals.h"
33#include "dbus-protocol.h"
34#include "dbus-string.h"
35#include "dbus-sysdeps.h"
36#include "dbus-sysdeps-win.h"
37#include "dbus-sockets-win.h"
38#include "dbus-memory.h"
39#include "dbus-pipe.h"
40
41#include <stdio.h>
42#include <stdlib.h>
43#if HAVE_ERRNO_H
44#include <errno.h>
45#endif
46#include <winsock2.h> // WSA error codes
47
48#ifndef DBUS_WINCE
49#include <io.h>
50#include <lm.h>
51#include <sys/stat.h>
52#endif
53
54
66 DBusPipe *print_pid_pipe,
67 DBusError *error,
68 dbus_bool_t keep_umask)
69{
71 "Cannot daemonize on Windows");
72 return FALSE;
73}
74
83static dbus_bool_t
84_dbus_write_pid_file (const DBusString *filename,
85 unsigned long pid,
86 DBusError *error)
87{
88 const char *cfilename;
89 HANDLE hnd;
90 char pidstr[20];
91 int total;
92 int bytes_to_write;
93
94 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
95
96 cfilename = _dbus_string_get_const_data (filename);
97
98 hnd = CreateFileA (cfilename, GENERIC_WRITE,
99 FILE_SHARE_READ | FILE_SHARE_WRITE,
100 NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL,
101 INVALID_HANDLE_VALUE);
102 if (hnd == INVALID_HANDLE_VALUE)
103 {
104 char *emsg = _dbus_win_error_string (GetLastError ());
105 dbus_set_error (error, _dbus_win_error_from_last_error (),
106 "Could not create PID file %s: %s",
107 cfilename, emsg);
108 _dbus_win_free_error_string (emsg);
109 return FALSE;
110 }
111
112 if (snprintf (pidstr, sizeof (pidstr), "%lu\n", pid) < 0)
113 {
115 "Failed to format PID for \"%s\": %s", cfilename,
117 CloseHandle (hnd);
118 return FALSE;
119 }
120
121 total = 0;
122 bytes_to_write = strlen (pidstr);;
123
124 while (total < bytes_to_write)
125 {
126 DWORD bytes_written;
127 BOOL res;
128
129 res = WriteFile (hnd, pidstr + total, bytes_to_write - total,
130 &bytes_written, NULL);
131
132 if (res == 0 || bytes_written <= 0)
133 {
134 char *emsg = _dbus_win_error_string (GetLastError ());
135 dbus_set_error (error, _dbus_win_error_from_last_error (),
136 "Could not write to %s: %s", cfilename, emsg);
137 _dbus_win_free_error_string (emsg);
138 CloseHandle (hnd);
139 return FALSE;
140 }
141
142 total += bytes_written;
143 }
144
145 if (CloseHandle (hnd) == 0)
146 {
147 char *emsg = _dbus_win_error_string (GetLastError ());
148 dbus_set_error (error, _dbus_win_error_from_last_error (),
149 "Could not close file %s: %s",
150 cfilename, emsg);
151 _dbus_win_free_error_string (emsg);
152
153 return FALSE;
154 }
155
156 return TRUE;
157}
158
172 DBusPipe *print_pid_pipe,
173 dbus_pid_t pid_to_write,
174 DBusError *error)
175{
176 if (pidfile)
177 {
178 _dbus_verbose ("writing pid file %s\n", _dbus_string_get_const_data (pidfile));
179 if (!_dbus_write_pid_file (pidfile,
180 pid_to_write,
181 error))
182 {
183 _dbus_verbose ("pid file write failed\n");
184 _DBUS_ASSERT_ERROR_IS_SET(error);
185 return FALSE;
186 }
187 }
188 else
189 {
190 _dbus_verbose ("No pid file requested\n");
191 }
192
193 if (print_pid_pipe != NULL && _dbus_pipe_is_valid (print_pid_pipe))
194 {
195 DBusString pid;
196 int bytes;
197
198 _dbus_verbose ("writing our pid to pipe %d\n", print_pid_pipe->fd);
199
200 if (!_dbus_string_init (&pid))
201 {
202 _DBUS_SET_OOM (error);
203 return FALSE;
204 }
205
206 if (!_dbus_string_append_int (&pid, pid_to_write) ||
207 !_dbus_string_append (&pid, "\n"))
208 {
209 _dbus_string_free (&pid);
210 _DBUS_SET_OOM (error);
211 return FALSE;
212 }
213
214 bytes = _dbus_string_get_length (&pid);
215 if (_dbus_pipe_write (print_pid_pipe, &pid, 0, bytes, error) != bytes)
216 {
217 /* _dbus_pipe_write sets error only on failure, not short write */
218 if (error != NULL && !dbus_error_is_set(error))
219 {
221 "Printing message bus PID: did not write enough bytes\n");
222 }
223 _dbus_string_free (&pid);
224 return FALSE;
225 }
226
227 _dbus_string_free (&pid);
228 }
229 else
230 {
231 _dbus_verbose ("No pid pipe to write to\n");
232 }
233
234 return TRUE;
235}
236
244_dbus_verify_daemon_user (const char *user)
245{
246 return TRUE;
247}
248
258 DBusError *error)
259{
260 return TRUE;
261}
262
263static void
264fd_limit_not_supported (DBusError *error)
265{
267 "cannot change fd limit on this platform");
268}
269
270DBusRLimit *
271_dbus_rlimit_save_fd_limit (DBusError *error)
272{
273 fd_limit_not_supported (error);
274 return NULL;
275}
276
278_dbus_rlimit_raise_fd_limit (DBusError *error)
279{
280 fd_limit_not_supported (error);
281 return FALSE;
282}
283
285_dbus_rlimit_restore_fd_limit (DBusRLimit *saved,
286 DBusError *error)
287{
288 fd_limit_not_supported (error);
289 return FALSE;
290}
291
292void
293_dbus_rlimit_free (DBusRLimit *lim)
294{
295 /* _dbus_rlimit_save_fd_limit() cannot return non-NULL on Windows
296 * so there cannot be anything to free */
297 _dbus_assert (lim == NULL);
298}
299
309_dbus_stat(const DBusString *filename,
310 DBusStat *statbuf,
311 DBusError *error)
312{
313 const char *filename_c;
314 WIN32_FILE_ATTRIBUTE_DATA wfad;
315 char *lastdot;
316
317 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
318
319 filename_c = _dbus_string_get_const_data (filename);
320
321 if (!GetFileAttributesExA (filename_c, GetFileExInfoStandard, &wfad))
322 {
323 _dbus_win_set_error_from_win_error (error, GetLastError ());
324 return FALSE;
325 }
326
327 if (wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
328 statbuf->mode = _S_IFDIR;
329 else
330 statbuf->mode = _S_IFREG;
331
332 statbuf->mode |= _S_IREAD;
333 if (wfad.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
334 statbuf->mode |= _S_IWRITE;
335
336 lastdot = strrchr (filename_c, '.');
337 if (lastdot && stricmp (lastdot, ".exe") == 0)
338 statbuf->mode |= _S_IEXEC;
339
340 statbuf->mode |= (statbuf->mode & 0700) >> 3;
341 statbuf->mode |= (statbuf->mode & 0700) >> 6;
342
343 statbuf->nlink = 1;
344
345#ifdef ENABLE_UID_TO_SID
346 {
347 PSID owner_sid, group_sid;
348 PSECURITY_DESCRIPTOR sd;
349
350 sd = NULL;
351 rc = GetNamedSecurityInfo ((char *) filename_c, SE_FILE_OBJECT,
352 OWNER_SECURITY_INFORMATION |
353 GROUP_SECURITY_INFORMATION,
354 &owner_sid, &group_sid,
355 NULL, NULL,
356 &sd);
357 if (rc != ERROR_SUCCESS)
358 {
359 _dbus_win_set_error_from_win_error (error, rc);
360 if (sd != NULL)
361 LocalFree (sd);
362 return FALSE;
363 }
364
365 /* FIXME */
366 statbuf->uid = _dbus_win_sid_to_uid_t (owner_sid);
367 statbuf->gid = _dbus_win_sid_to_uid_t (group_sid);
368
369 LocalFree (sd);
370 }
371#else
372 statbuf->uid = DBUS_UID_UNSET;
373 statbuf->gid = DBUS_GID_UNSET;
374#endif
375
376 statbuf->size = ((dbus_int64_t) wfad.nFileSizeHigh << 32) + wfad.nFileSizeLow;
377
378 statbuf->atime =
379 (((dbus_int64_t) wfad.ftLastAccessTime.dwHighDateTime << 32) +
380 wfad.ftLastAccessTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
381
382 statbuf->mtime =
383 (((dbus_int64_t) wfad.ftLastWriteTime.dwHighDateTime << 32) +
384 wfad.ftLastWriteTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
385
386 statbuf->ctime =
387 (((dbus_int64_t) wfad.ftCreationTime.dwHighDateTime << 32) +
388 wfad.ftCreationTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
389
390 return TRUE;
391}
392
396struct DBusDirIter
397 {
398 HANDLE handle;
399 WIN32_FIND_DATAA fileinfo; /* from FindFirst/FindNext */
400 dbus_bool_t finished; /* true if there are no more entries */
401 int offset;
402 };
403
413 DBusError *error)
414{
415 DBusDirIter *iter;
416 DBusString filespec;
417
418 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
419
420 if (!_dbus_string_init_from_string (&filespec, filename))
421 {
423 "Could not allocate memory for directory filename copy");
424 return NULL;
425 }
426
427 if (_dbus_string_ends_with_c_str (&filespec, "/") || _dbus_string_ends_with_c_str (&filespec, "\\") )
428 {
429 if (!_dbus_string_append (&filespec, "*"))
430 {
431 _dbus_string_free (&filespec);
433 "Could not append filename wildcard");
434 return NULL;
435 }
436 }
437 else if (!_dbus_string_ends_with_c_str (&filespec, "*"))
438 {
439 if (!_dbus_string_append (&filespec, "\\*"))
440 {
441 _dbus_string_free (&filespec);
443 "Could not append filename wildcard 2");
444 return NULL;
445 }
446 }
447
448 iter = dbus_new0 (DBusDirIter, 1);
449 if (iter == NULL)
450 {
451 _dbus_string_free (&filespec);
453 "Could not allocate memory for directory iterator");
454 return NULL;
455 }
456
457 iter->finished = FALSE;
458 iter->offset = 0;
459 iter->handle = FindFirstFileA (_dbus_string_get_const_data (&filespec), &(iter->fileinfo));
460 if (iter->handle == INVALID_HANDLE_VALUE)
461 {
462 if (GetLastError () == ERROR_NO_MORE_FILES)
463 iter->finished = TRUE;
464 else
465 {
466 char *emsg = _dbus_win_error_string (GetLastError ());
467 dbus_set_error (error, _dbus_win_error_from_last_error (),
468 "Failed to read directory \"%s\": %s",
469 _dbus_string_get_const_data (filename), emsg);
470 _dbus_win_free_error_string (emsg);
471 dbus_free (iter);
472 _dbus_string_free (&filespec);
473 return NULL;
474 }
475 }
476 _dbus_string_free (&filespec);
477 return iter;
478}
479
492 DBusString *filename,
493 DBusError *error)
494{
495 int saved_err = GetLastError();
496
497 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
498
499again:
500 SetLastError (0);
501
502 if (!iter || iter->finished)
503 return FALSE;
504
505 if (iter->offset > 0)
506 {
507 if (FindNextFileA (iter->handle, &(iter->fileinfo)) == 0)
508 {
509 if (GetLastError() == ERROR_NO_MORE_FILES)
510 {
511 SetLastError(saved_err);
512 iter->finished = 1;
513 }
514 else
515 {
516 char *emsg = _dbus_win_error_string (GetLastError ());
517 dbus_set_error (error, _dbus_win_error_from_last_error (),
518 "Failed to get next in directory: %s", emsg);
519 _dbus_win_free_error_string (emsg);
520 return FALSE;
521 }
522 }
523 }
524
525 iter->offset++;
526
527 if (iter->finished)
528 return FALSE;
529
530 if (iter->fileinfo.cFileName[0] == '.' &&
531 (iter->fileinfo.cFileName[1] == '\0' ||
532 (iter->fileinfo.cFileName[1] == '.' && iter->fileinfo.cFileName[2] == '\0')))
533 goto again;
534
535 _dbus_string_set_length (filename, 0);
536 if (!_dbus_string_append (filename, iter->fileinfo.cFileName))
537 {
539 "No memory to read directory entry");
540 return FALSE;
541 }
542
543 return TRUE;
544}
545
549void
551{
552 if (!iter)
553 return;
554 FindClose(iter->handle);
555 dbus_free (iter);
556}
557 /* End of DBusInternalsUtils functions */
559
573 DBusString *dirname)
574{
575 int sep;
576
577 _dbus_assert (filename != dirname);
578 _dbus_assert (filename != NULL);
579 _dbus_assert (dirname != NULL);
580
581 /* Ignore any separators on the end */
582 sep = _dbus_string_get_length (filename);
583 if (sep == 0)
584 return _dbus_string_append (dirname, "."); /* empty string passed in */
585
586 while (sep > 0 &&
587 (_dbus_string_get_byte (filename, sep - 1) == '/' ||
588 _dbus_string_get_byte (filename, sep - 1) == '\\'))
589 --sep;
590
591 _dbus_assert (sep >= 0);
592
593 if (sep == 0 ||
594 (sep == 2 &&
595 _dbus_string_get_byte (filename, 1) == ':' &&
596 isalpha (_dbus_string_get_byte (filename, 0))))
597 return _dbus_string_copy_len (filename, 0, sep + 1,
598 dirname, _dbus_string_get_length (dirname));
599
600 {
601 int sep1, sep2;
602 _dbus_string_find_byte_backward (filename, sep, '/', &sep1);
603 _dbus_string_find_byte_backward (filename, sep, '\\', &sep2);
604
605 sep = MAX (sep1, sep2);
606 }
607 if (sep < 0)
608 return _dbus_string_append (dirname, ".");
609
610 while (sep > 0 &&
611 (_dbus_string_get_byte (filename, sep - 1) == '/' ||
612 _dbus_string_get_byte (filename, sep - 1) == '\\'))
613 --sep;
614
615 _dbus_assert (sep >= 0);
616
617 if ((sep == 0 ||
618 (sep == 2 &&
619 _dbus_string_get_byte (filename, 1) == ':' &&
620 isalpha (_dbus_string_get_byte (filename, 0))))
621 &&
622 (_dbus_string_get_byte (filename, sep) == '/' ||
623 _dbus_string_get_byte (filename, sep) == '\\'))
624 return _dbus_string_copy_len (filename, 0, sep + 1,
625 dirname, _dbus_string_get_length (dirname));
626 else
627 return _dbus_string_copy_len (filename, 0, sep - 0,
628 dirname, _dbus_string_get_length (dirname));
629}
630
631
641{
642 return FALSE;
643}
644
646{
647 return TRUE;
648}
649
650/*=====================================================================
651 unix emulation functions - should be removed sometime in the future
652 =====================================================================*/
653
654static void
655set_unix_uid_unsupported (DBusError *error)
656{
658 "UNIX user IDs not supported on Windows");
659}
660
672 DBusError *error)
673{
674 set_unix_uid_unsupported (error);
675 return FALSE;
676}
677
678
689 dbus_gid_t *gid_p)
690{
691 return FALSE;
692}
693
704 dbus_uid_t *uid_p)
705{
706 return FALSE;
707}
708
709
723 dbus_gid_t **group_ids,
724 int *n_group_ids,
725 DBusError *error)
726{
727 set_unix_uid_unsupported (error);
728 return FALSE;
729}
730
731
732 /* DBusString stuff */
734
735/************************************************************************
736
737 error handling
738
739 ************************************************************************/
740
741
742
743
744
745/* lan manager error codes */
746const char*
747_dbus_lm_strerror(int error_number)
748{
749#ifdef DBUS_WINCE
750 // TODO
751 return "unknown";
752#else
753 const char *msg;
754 switch (error_number)
755 {
756 case NERR_NetNotStarted:
757 return "The workstation driver is not installed.";
758 case NERR_UnknownServer:
759 return "The server could not be located.";
760 case NERR_ShareMem:
761 return "An internal error occurred. The network cannot access a shared memory segment.";
762 case NERR_NoNetworkResource:
763 return "A network resource shortage occurred.";
764 case NERR_RemoteOnly:
765 return "This operation is not supported on workstations.";
766 case NERR_DevNotRedirected:
767 return "The device is not connected.";
768 case NERR_ServerNotStarted:
769 return "The Server service is not started.";
770 case NERR_ItemNotFound:
771 return "The queue is empty.";
772 case NERR_UnknownDevDir:
773 return "The device or directory does not exist.";
774 case NERR_RedirectedPath:
775 return "The operation is invalid on a redirected resource.";
776 case NERR_DuplicateShare:
777 return "The name has already been shared.";
778 case NERR_NoRoom:
779 return "The server is currently out of the requested resource.";
780 case NERR_TooManyItems:
781 return "Requested addition of items exceeds the maximum allowed.";
782 case NERR_InvalidMaxUsers:
783 return "The Peer service supports only two simultaneous users.";
784 case NERR_BufTooSmall:
785 return "The API return buffer is too small.";
786 case NERR_RemoteErr:
787 return "A remote API error occurred.";
788 case NERR_LanmanIniError:
789 return "An error occurred when opening or reading the configuration file.";
790 case NERR_NetworkError:
791 return "A general network error occurred.";
792 case NERR_WkstaInconsistentState:
793 return "The Workstation service is in an inconsistent state. Restart the computer before restarting the Workstation service.";
794 case NERR_WkstaNotStarted:
795 return "The Workstation service has not been started.";
796 case NERR_BrowserNotStarted:
797 return "The requested information is not available.";
798 case NERR_InternalError:
799 return "An internal error occurred.";
800 case NERR_BadTransactConfig:
801 return "The server is not configured for transactions.";
802 case NERR_InvalidAPI:
803 return "The requested API is not supported on the remote server.";
804 case NERR_BadEventName:
805 return "The event name is invalid.";
806 case NERR_DupNameReboot:
807 return "The computer name already exists on the network. Change it and restart the computer.";
808 case NERR_CfgCompNotFound:
809 return "The specified component could not be found in the configuration information.";
810 case NERR_CfgParamNotFound:
811 return "The specified parameter could not be found in the configuration information.";
812 case NERR_LineTooLong:
813 return "A line in the configuration file is too long.";
814 case NERR_QNotFound:
815 return "The printer does not exist.";
816 case NERR_JobNotFound:
817 return "The print job does not exist.";
818 case NERR_DestNotFound:
819 return "The printer destination cannot be found.";
820 case NERR_DestExists:
821 return "The printer destination already exists.";
822 case NERR_QExists:
823 return "The printer queue already exists.";
824 case NERR_QNoRoom:
825 return "No more printers can be added.";
826 case NERR_JobNoRoom:
827 return "No more print jobs can be added.";
828 case NERR_DestNoRoom:
829 return "No more printer destinations can be added.";
830 case NERR_DestIdle:
831 return "This printer destination is idle and cannot accept control operations.";
832 case NERR_DestInvalidOp:
833 return "This printer destination request contains an invalid control function.";
834 case NERR_ProcNoRespond:
835 return "The print processor is not responding.";
836 case NERR_SpoolerNotLoaded:
837 return "The spooler is not running.";
838 case NERR_DestInvalidState:
839 return "This operation cannot be performed on the print destination in its current state.";
840 case NERR_QInvalidState:
841 return "This operation cannot be performed on the printer queue in its current state.";
842 case NERR_JobInvalidState:
843 return "This operation cannot be performed on the print job in its current state.";
844 case NERR_SpoolNoMemory:
845 return "A spooler memory allocation failure occurred.";
846 case NERR_DriverNotFound:
847 return "The device driver does not exist.";
848 case NERR_DataTypeInvalid:
849 return "The data type is not supported by the print processor.";
850 case NERR_ProcNotFound:
851 return "The print processor is not installed.";
852 case NERR_ServiceTableLocked:
853 return "The service database is locked.";
854 case NERR_ServiceTableFull:
855 return "The service table is full.";
856 case NERR_ServiceInstalled:
857 return "The requested service has already been started.";
858 case NERR_ServiceEntryLocked:
859 return "The service does not respond to control actions.";
860 case NERR_ServiceNotInstalled:
861 return "The service has not been started.";
862 case NERR_BadServiceName:
863 return "The service name is invalid.";
864 case NERR_ServiceCtlTimeout:
865 return "The service is not responding to the control function.";
866 case NERR_ServiceCtlBusy:
867 return "The service control is busy.";
868 case NERR_BadServiceProgName:
869 return "The configuration file contains an invalid service program name.";
870 case NERR_ServiceNotCtrl:
871 return "The service could not be controlled in its present state.";
872 case NERR_ServiceKillProc:
873 return "The service ended abnormally.";
874 case NERR_ServiceCtlNotValid:
875 return "The requested pause or stop is not valid for this service.";
876 case NERR_NotInDispatchTbl:
877 return "The service control dispatcher could not find the service name in the dispatch table.";
878 case NERR_BadControlRecv:
879 return "The service control dispatcher pipe read failed.";
880 case NERR_ServiceNotStarting:
881 return "A thread for the new service could not be created.";
882 case NERR_AlreadyLoggedOn:
883 return "This workstation is already logged on to the local-area network.";
884 case NERR_NotLoggedOn:
885 return "The workstation is not logged on to the local-area network.";
886 case NERR_BadUsername:
887 return "The user name or group name parameter is invalid.";
888 case NERR_BadPassword:
889 return "The password parameter is invalid.";
890 case NERR_UnableToAddName_W:
891 return "@W The logon processor did not add the message alias.";
892 case NERR_UnableToAddName_F:
893 return "The logon processor did not add the message alias.";
894 case NERR_UnableToDelName_W:
895 return "@W The logoff processor did not delete the message alias.";
896 case NERR_UnableToDelName_F:
897 return "The logoff processor did not delete the message alias.";
898 case NERR_LogonsPaused:
899 return "Network logons are paused.";
900 case NERR_LogonServerConflict:
901 return "A centralized logon-server conflict occurred.";
902 case NERR_LogonNoUserPath:
903 return "The server is configured without a valid user path.";
904 case NERR_LogonScriptError:
905 return "An error occurred while loading or running the logon script.";
906 case NERR_StandaloneLogon:
907 return "The logon server was not specified. Your computer will be logged on as STANDALONE.";
908 case NERR_LogonServerNotFound:
909 return "The logon server could not be found.";
910 case NERR_LogonDomainExists:
911 return "There is already a logon domain for this computer.";
912 case NERR_NonValidatedLogon:
913 return "The logon server could not validate the logon.";
914 case NERR_ACFNotFound:
915 return "The security database could not be found.";
916 case NERR_GroupNotFound:
917 return "The group name could not be found.";
918 case NERR_UserNotFound:
919 return "The user name could not be found.";
920 case NERR_ResourceNotFound:
921 return "The resource name could not be found.";
922 case NERR_GroupExists:
923 return "The group already exists.";
924 case NERR_UserExists:
925 return "The user account already exists.";
926 case NERR_ResourceExists:
927 return "The resource permission list already exists.";
928 case NERR_NotPrimary:
929 return "This operation is only allowed on the primary domain controller of the domain.";
930 case NERR_ACFNotLoaded:
931 return "The security database has not been started.";
932 case NERR_ACFNoRoom:
933 return "There are too many names in the user accounts database.";
934 case NERR_ACFFileIOFail:
935 return "A disk I/O failure occurred.";
936 case NERR_ACFTooManyLists:
937 return "The limit of 64 entries per resource was exceeded.";
938 case NERR_UserLogon:
939 return "Deleting a user with a session is not allowed.";
940 case NERR_ACFNoParent:
941 return "The parent directory could not be located.";
942 case NERR_CanNotGrowSegment:
943 return "Unable to add to the security database session cache segment.";
944 case NERR_SpeGroupOp:
945 return "This operation is not allowed on this special group.";
946 case NERR_NotInCache:
947 return "This user is not cached in user accounts database session cache.";
948 case NERR_UserInGroup:
949 return "The user already belongs to this group.";
950 case NERR_UserNotInGroup:
951 return "The user does not belong to this group.";
952 case NERR_AccountUndefined:
953 return "This user account is undefined.";
954 case NERR_AccountExpired:
955 return "This user account has expired.";
956 case NERR_InvalidWorkstation:
957 return "The user is not allowed to log on from this workstation.";
958 case NERR_InvalidLogonHours:
959 return "The user is not allowed to log on at this time.";
960 case NERR_PasswordExpired:
961 return "The password of this user has expired.";
962 case NERR_PasswordCantChange:
963 return "The password of this user cannot change.";
964 case NERR_PasswordHistConflict:
965 return "This password cannot be used now.";
966 case NERR_PasswordTooShort:
967 return "The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements.";
968 case NERR_PasswordTooRecent:
969 return "The password of this user is too recent to change.";
970 case NERR_InvalidDatabase:
971 return "The security database is corrupted.";
972 case NERR_DatabaseUpToDate:
973 return "No updates are necessary to this replicant network/local security database.";
974 case NERR_SyncRequired:
975 return "This replicant database is outdated; synchronization is required.";
976 case NERR_UseNotFound:
977 return "The network connection could not be found.";
978 case NERR_BadAsgType:
979 return "This asg_type is invalid.";
980 case NERR_DeviceIsShared:
981 return "This device is currently being shared.";
982 case NERR_NoComputerName:
983 return "The computer name could not be added as a message alias. The name may already exist on the network.";
984 case NERR_MsgAlreadyStarted:
985 return "The Messenger service is already started.";
986 case NERR_MsgInitFailed:
987 return "The Messenger service failed to start.";
988 case NERR_NameNotFound:
989 return "The message alias could not be found on the network.";
990 case NERR_AlreadyForwarded:
991 return "This message alias has already been forwarded.";
992 case NERR_AddForwarded:
993 return "This message alias has been added but is still forwarded.";
994 case NERR_AlreadyExists:
995 return "This message alias already exists locally.";
996 case NERR_TooManyNames:
997 return "The maximum number of added message aliases has been exceeded.";
998 case NERR_DelComputerName:
999 return "The computer name could not be deleted.";
1000 case NERR_LocalForward:
1001 return "Messages cannot be forwarded back to the same workstation.";
1002 case NERR_GrpMsgProcessor:
1003 return "An error occurred in the domain message processor.";
1004 case NERR_PausedRemote:
1005 return "The message was sent, but the recipient has paused the Messenger service.";
1006 case NERR_BadReceive:
1007 return "The message was sent but not received.";
1008 case NERR_NameInUse:
1009 return "The message alias is currently in use. Try again later.";
1010 case NERR_MsgNotStarted:
1011 return "The Messenger service has not been started.";
1012 case NERR_NotLocalName:
1013 return "The name is not on the local computer.";
1014 case NERR_NoForwardName:
1015 return "The forwarded message alias could not be found on the network.";
1016 case NERR_RemoteFull:
1017 return "The message alias table on the remote station is full.";
1018 case NERR_NameNotForwarded:
1019 return "Messages for this alias are not currently being forwarded.";
1020 case NERR_TruncatedBroadcast:
1021 return "The broadcast message was truncated.";
1022 case NERR_InvalidDevice:
1023 return "This is an invalid device name.";
1024 case NERR_WriteFault:
1025 return "A write fault occurred.";
1026 case NERR_DuplicateName:
1027 return "A duplicate message alias exists on the network.";
1028 case NERR_DeleteLater:
1029 return "@W This message alias will be deleted later.";
1030 case NERR_IncompleteDel:
1031 return "The message alias was not successfully deleted from all networks.";
1032 case NERR_MultipleNets:
1033 return "This operation is not supported on computers with multiple networks.";
1034 case NERR_NetNameNotFound:
1035 return "This shared resource does not exist.";
1036 case NERR_DeviceNotShared:
1037 return "This device is not shared.";
1038 case NERR_ClientNameNotFound:
1039 return "A session does not exist with that computer name.";
1040 case NERR_FileIdNotFound:
1041 return "There is not an open file with that identification number.";
1042 case NERR_ExecFailure:
1043 return "A failure occurred when executing a remote administration command.";
1044 case NERR_TmpFile:
1045 return "A failure occurred when opening a remote temporary file.";
1046 case NERR_TooMuchData:
1047 return "The data returned from a remote administration command has been truncated to 64K.";
1048 case NERR_DeviceShareConflict:
1049 return "This device cannot be shared as both a spooled and a non-spooled resource.";
1050 case NERR_BrowserTableIncomplete:
1051 return "The information in the list of servers may be incorrect.";
1052 case NERR_NotLocalDomain:
1053 return "The computer is not active in this domain.";
1054#ifdef NERR_IsDfsShare
1055
1056 case NERR_IsDfsShare:
1057 return "The share must be removed from the Distributed File System before it can be deleted.";
1058#endif
1059
1060 case NERR_DevInvalidOpCode:
1061 return "The operation is invalid for this device.";
1062 case NERR_DevNotFound:
1063 return "This device cannot be shared.";
1064 case NERR_DevNotOpen:
1065 return "This device was not open.";
1066 case NERR_BadQueueDevString:
1067 return "This device name list is invalid.";
1068 case NERR_BadQueuePriority:
1069 return "The queue priority is invalid.";
1070 case NERR_NoCommDevs:
1071 return "There are no shared communication devices.";
1072 case NERR_QueueNotFound:
1073 return "The queue you specified does not exist.";
1074 case NERR_BadDevString:
1075 return "This list of devices is invalid.";
1076 case NERR_BadDev:
1077 return "The requested device is invalid.";
1078 case NERR_InUseBySpooler:
1079 return "This device is already in use by the spooler.";
1080 case NERR_CommDevInUse:
1081 return "This device is already in use as a communication device.";
1082 case NERR_InvalidComputer:
1083 return "This computer name is invalid.";
1084 case NERR_MaxLenExceeded:
1085 return "The string and prefix specified are too long.";
1086 case NERR_BadComponent:
1087 return "This path component is invalid.";
1088 case NERR_CantType:
1089 return "Could not determine the type of input.";
1090 case NERR_TooManyEntries:
1091 return "The buffer for types is not big enough.";
1092 case NERR_ProfileFileTooBig:
1093 return "Profile files cannot exceed 64K.";
1094 case NERR_ProfileOffset:
1095 return "The start offset is out of range.";
1096 case NERR_ProfileCleanup:
1097 return "The system cannot delete current connections to network resources.";
1098 case NERR_ProfileUnknownCmd:
1099 return "The system was unable to parse the command line in this file.";
1100 case NERR_ProfileLoadErr:
1101 return "An error occurred while loading the profile file.";
1102 case NERR_ProfileSaveErr:
1103 return "@W Errors occurred while saving the profile file. The profile was partially saved.";
1104 case NERR_LogOverflow:
1105 return "Log file %1 is full.";
1106 case NERR_LogFileChanged:
1107 return "This log file has changed between reads.";
1108 case NERR_LogFileCorrupt:
1109 return "Log file %1 is corrupt.";
1110 case NERR_SourceIsDir:
1111 return "The source path cannot be a directory.";
1112 case NERR_BadSource:
1113 return "The source path is illegal.";
1114 case NERR_BadDest:
1115 return "The destination path is illegal.";
1116 case NERR_DifferentServers:
1117 return "The source and destination paths are on different servers.";
1118 case NERR_RunSrvPaused:
1119 return "The Run server you requested is paused.";
1120 case NERR_ErrCommRunSrv:
1121 return "An error occurred when communicating with a Run server.";
1122 case NERR_ErrorExecingGhost:
1123 return "An error occurred when starting a background process.";
1124 case NERR_ShareNotFound:
1125 return "The shared resource you are connected to could not be found.";
1126 case NERR_InvalidLana:
1127 return "The LAN adapter number is invalid.";
1128 case NERR_OpenFiles:
1129 return "There are open files on the connection.";
1130 case NERR_ActiveConns:
1131 return "Active connections still exist.";
1132 case NERR_BadPasswordCore:
1133 return "This share name or password is invalid.";
1134 case NERR_DevInUse:
1135 return "The device is being accessed by an active process.";
1136 case NERR_LocalDrive:
1137 return "The drive letter is in use locally.";
1138 case NERR_AlertExists:
1139 return "The specified client is already registered for the specified event.";
1140 case NERR_TooManyAlerts:
1141 return "The alert table is full.";
1142 case NERR_NoSuchAlert:
1143 return "An invalid or nonexistent alert name was raised.";
1144 case NERR_BadRecipient:
1145 return "The alert recipient is invalid.";
1146 case NERR_AcctLimitExceeded:
1147 return "A user's session with this server has been deleted.";
1148 case NERR_InvalidLogSeek:
1149 return "The log file does not contain the requested record number.";
1150 case NERR_BadUasConfig:
1151 return "The user accounts database is not configured correctly.";
1152 case NERR_InvalidUASOp:
1153 return "This operation is not permitted when the Netlogon service is running.";
1154 case NERR_LastAdmin:
1155 return "This operation is not allowed on the last administrative account.";
1156 case NERR_DCNotFound:
1157 return "Could not find domain controller for this domain.";
1158 case NERR_LogonTrackingError:
1159 return "Could not set logon information for this user.";
1160 case NERR_NetlogonNotStarted:
1161 return "The Netlogon service has not been started.";
1162 case NERR_CanNotGrowUASFile:
1163 return "Unable to add to the user accounts database.";
1164 case NERR_TimeDiffAtDC:
1165 return "This server's clock is not synchronized with the primary domain controller's clock.";
1166 case NERR_PasswordMismatch:
1167 return "A password mismatch has been detected.";
1168 case NERR_NoSuchServer:
1169 return "The server identification does not specify a valid server.";
1170 case NERR_NoSuchSession:
1171 return "The session identification does not specify a valid session.";
1172 case NERR_NoSuchConnection:
1173 return "The connection identification does not specify a valid connection.";
1174 case NERR_TooManyServers:
1175 return "There is no space for another entry in the table of available servers.";
1176 case NERR_TooManySessions:
1177 return "The server has reached the maximum number of sessions it supports.";
1178 case NERR_TooManyConnections:
1179 return "The server has reached the maximum number of connections it supports.";
1180 case NERR_TooManyFiles:
1181 return "The server cannot open more files because it has reached its maximum number.";
1182 case NERR_NoAlternateServers:
1183 return "There are no alternate servers registered on this server.";
1184 case NERR_TryDownLevel:
1185 return "Try down-level (remote admin protocol) version of API instead.";
1186 case NERR_UPSDriverNotStarted:
1187 return "The UPS driver could not be accessed by the UPS service.";
1188 case NERR_UPSInvalidConfig:
1189 return "The UPS service is not configured correctly.";
1190 case NERR_UPSInvalidCommPort:
1191 return "The UPS service could not access the specified Comm Port.";
1192 case NERR_UPSSignalAsserted:
1193 return "The UPS indicated a line fail or low battery situation. Service not started.";
1194 case NERR_UPSShutdownFailed:
1195 return "The UPS service failed to perform a system shut down.";
1196 case NERR_BadDosRetCode:
1197 return "The program below returned an MS-DOS error code:";
1198 case NERR_ProgNeedsExtraMem:
1199 return "The program below needs more memory:";
1200 case NERR_BadDosFunction:
1201 return "The program below called an unsupported MS-DOS function:";
1202 case NERR_RemoteBootFailed:
1203 return "The workstation failed to boot.";
1204 case NERR_BadFileCheckSum:
1205 return "The file below is corrupt.";
1206 case NERR_NoRplBootSystem:
1207 return "No loader is specified in the boot-block definition file.";
1208 case NERR_RplLoadrNetBiosErr:
1209 return "NetBIOS returned an error: The NCB and SMB are dumped above.";
1210 case NERR_RplLoadrDiskErr:
1211 return "A disk I/O error occurred.";
1212 case NERR_ImageParamErr:
1213 return "Image parameter substitution failed.";
1214 case NERR_TooManyImageParams:
1215 return "Too many image parameters cross disk sector boundaries.";
1216 case NERR_NonDosFloppyUsed:
1217 return "The image was not generated from an MS-DOS diskette formatted with /S.";
1218 case NERR_RplBootRestart:
1219 return "Remote boot will be restarted later.";
1220 case NERR_RplSrvrCallFailed:
1221 return "The call to the Remoteboot server failed.";
1222 case NERR_CantConnectRplSrvr:
1223 return "Cannot connect to the Remoteboot server.";
1224 case NERR_CantOpenImageFile:
1225 return "Cannot open image file on the Remoteboot server.";
1226 case NERR_CallingRplSrvr:
1227 return "Connecting to the Remoteboot server...";
1228 case NERR_StartingRplBoot:
1229 return "Connecting to the Remoteboot server...";
1230 case NERR_RplBootServiceTerm:
1231 return "Remote boot service was stopped; check the error log for the cause of the problem.";
1232 case NERR_RplBootStartFailed:
1233 return "Remote boot startup failed; check the error log for the cause of the problem.";
1234 case NERR_RPL_CONNECTED:
1235 return "A second connection to a Remoteboot resource is not allowed.";
1236 case NERR_BrowserConfiguredToNotRun:
1237 return "The browser service was configured with MaintainServerList=No.";
1238 case NERR_RplNoAdaptersStarted:
1239 return "Service failed to start since none of the network adapters started with this service.";
1240 case NERR_RplBadRegistry:
1241 return "Service failed to start due to bad startup information in the registry.";
1242 case NERR_RplBadDatabase:
1243 return "Service failed to start because its database is absent or corrupt.";
1244 case NERR_RplRplfilesShare:
1245 return "Service failed to start because RPLFILES share is absent.";
1246 case NERR_RplNotRplServer:
1247 return "Service failed to start because RPLUSER group is absent.";
1248 case NERR_RplCannotEnum:
1249 return "Cannot enumerate service records.";
1250 case NERR_RplWkstaInfoCorrupted:
1251 return "Workstation record information has been corrupted.";
1252 case NERR_RplWkstaNotFound:
1253 return "Workstation record was not found.";
1254 case NERR_RplWkstaNameUnavailable:
1255 return "Workstation name is in use by some other workstation.";
1256 case NERR_RplProfileInfoCorrupted:
1257 return "Profile record information has been corrupted.";
1258 case NERR_RplProfileNotFound:
1259 return "Profile record was not found.";
1260 case NERR_RplProfileNameUnavailable:
1261 return "Profile name is in use by some other profile.";
1262 case NERR_RplProfileNotEmpty:
1263 return "There are workstations using this profile.";
1264 case NERR_RplConfigInfoCorrupted:
1265 return "Configuration record information has been corrupted.";
1266 case NERR_RplConfigNotFound:
1267 return "Configuration record was not found.";
1268 case NERR_RplAdapterInfoCorrupted:
1269 return "Adapter ID record information has been corrupted.";
1270 case NERR_RplInternal:
1271 return "An internal service error has occurred.";
1272 case NERR_RplVendorInfoCorrupted:
1273 return "Vendor ID record information has been corrupted.";
1274 case NERR_RplBootInfoCorrupted:
1275 return "Boot block record information has been corrupted.";
1276 case NERR_RplWkstaNeedsUserAcct:
1277 return "The user account for this workstation record is missing.";
1278 case NERR_RplNeedsRPLUSERAcct:
1279 return "The RPLUSER local group could not be found.";
1280 case NERR_RplBootNotFound:
1281 return "Boot block record was not found.";
1282 case NERR_RplIncompatibleProfile:
1283 return "Chosen profile is incompatible with this workstation.";
1284 case NERR_RplAdapterNameUnavailable:
1285 return "Chosen network adapter ID is in use by some other workstation.";
1286 case NERR_RplConfigNotEmpty:
1287 return "There are profiles using this configuration.";
1288 case NERR_RplBootInUse:
1289 return "There are workstations, profiles, or configurations using this boot block.";
1290 case NERR_RplBackupDatabase:
1291 return "Service failed to backup Remoteboot database.";
1292 case NERR_RplAdapterNotFound:
1293 return "Adapter record was not found.";
1294 case NERR_RplVendorNotFound:
1295 return "Vendor record was not found.";
1296 case NERR_RplVendorNameUnavailable:
1297 return "Vendor name is in use by some other vendor record.";
1298 case NERR_RplBootNameUnavailable:
1299 return "(boot name, vendor ID) is in use by some other boot block record.";
1300 case NERR_RplConfigNameUnavailable:
1301 return "Configuration name is in use by some other configuration.";
1302 case NERR_DfsInternalCorruption:
1303 return "The internal database maintained by the Dfs service is corrupt.";
1304 case NERR_DfsVolumeDataCorrupt:
1305 return "One of the records in the internal Dfs database is corrupt.";
1306 case NERR_DfsNoSuchVolume:
1307 return "There is no DFS name whose entry path matches the input Entry Path.";
1308 case NERR_DfsVolumeAlreadyExists:
1309 return "A root or link with the given name already exists.";
1310 case NERR_DfsAlreadyShared:
1311 return "The server share specified is already shared in the Dfs.";
1312 case NERR_DfsNoSuchShare:
1313 return "The indicated server share does not support the indicated DFS namespace.";
1314 case NERR_DfsNotALeafVolume:
1315 return "The operation is not valid on this portion of the namespace.";
1316 case NERR_DfsLeafVolume:
1317 return "The operation is not valid on this portion of the namespace.";
1318 case NERR_DfsVolumeHasMultipleServers:
1319 return "The operation is ambiguous because the link has multiple servers.";
1320 case NERR_DfsCantCreateJunctionPoint:
1321 return "Unable to create a link.";
1322 case NERR_DfsServerNotDfsAware:
1323 return "The server is not Dfs Aware.";
1324 case NERR_DfsBadRenamePath:
1325 return "The specified rename target path is invalid.";
1326 case NERR_DfsVolumeIsOffline:
1327 return "The specified DFS link is offline.";
1328 case NERR_DfsNoSuchServer:
1329 return "The specified server is not a server for this link.";
1330 case NERR_DfsCyclicalName:
1331 return "A cycle in the Dfs name was detected.";
1332 case NERR_DfsNotSupportedInServerDfs:
1333 return "The operation is not supported on a server-based Dfs.";
1334 case NERR_DfsDuplicateService:
1335 return "This link is already supported by the specified server-share.";
1336 case NERR_DfsCantRemoveLastServerShare:
1337 return "Can't remove the last server-share supporting this root or link.";
1338 case NERR_DfsVolumeIsInterDfs:
1339 return "The operation is not supported for an Inter-DFS link.";
1340 case NERR_DfsInconsistent:
1341 return "The internal state of the Dfs Service has become inconsistent.";
1342 case NERR_DfsServerUpgraded:
1343 return "The Dfs Service has been installed on the specified server.";
1344 case NERR_DfsDataIsIdentical:
1345 return "The Dfs data being reconciled is identical.";
1346 case NERR_DfsCantRemoveDfsRoot:
1347 return "The DFS root cannot be deleted. Uninstall DFS if required.";
1348 case NERR_DfsChildOrParentInDfs:
1349 return "A child or parent directory of the share is already in a Dfs.";
1350 case NERR_DfsInternalError:
1351 return "Dfs internal error.";
1352 /* the following are not defined in mingw */
1353#if 0
1354
1355 case NERR_SetupAlreadyJoined:
1356 return "This machine is already joined to a domain.";
1357 case NERR_SetupNotJoined:
1358 return "This machine is not currently joined to a domain.";
1359 case NERR_SetupDomainController:
1360 return "This machine is a domain controller and cannot be unjoined from a domain.";
1361 case NERR_DefaultJoinRequired:
1362 return "The destination domain controller does not support creating machine accounts in OUs.";
1363 case NERR_InvalidWorkgroupName:
1364 return "The specified workgroup name is invalid.";
1365 case NERR_NameUsesIncompatibleCodePage:
1366 return "The specified computer name is incompatible with the default language used on the domain controller.";
1367 case NERR_ComputerAccountNotFound:
1368 return "The specified computer account could not be found.";
1369 case NERR_PersonalSku:
1370 return "This version of Windows cannot be joined to a domain.";
1371 case NERR_PasswordMustChange:
1372 return "The password must change at the next logon.";
1373 case NERR_AccountLockedOut:
1374 return "The account is locked out.";
1375 case NERR_PasswordTooLong:
1376 return "The password is too long.";
1377 case NERR_PasswordNotComplexEnough:
1378 return "The password does not meet the complexity policy.";
1379 case NERR_PasswordFilterError:
1380 return "The password does not meet the requirements of the password filter DLLs.";
1381#endif
1382
1383 default:
1384 msg = strerror (error_number);
1385
1386 if (msg == NULL)
1387 msg = "unknown";
1388
1389 return msg;
1390 }
1391#endif //DBUS_WINCE
1392}
1393
1409_dbus_command_for_pid (unsigned long pid,
1410 DBusString *str,
1411 int max_len,
1412 DBusError *error)
1413{
1415 "_dbus_command_for_pid() not implemented on Windows");
1416 return FALSE;
1417}
1418
1429{
1430#ifndef DBUS_PREFIX
1431 /* leave path unchanged */
1432 return TRUE;
1433#else
1434 DBusString runtime_prefix;
1435 int i;
1436
1437 if (!_dbus_string_init (&runtime_prefix))
1438 return FALSE;
1439
1440 if (!_dbus_get_install_root (&runtime_prefix))
1441 {
1442 _dbus_string_free (&runtime_prefix);
1443 return FALSE;
1444 }
1445
1446 if (_dbus_string_get_length (&runtime_prefix) == 0)
1447 {
1448 /* cannot determine install root, leave path unchanged */
1449 _dbus_string_free (&runtime_prefix);
1450 return TRUE;
1451 }
1452
1453 if (_dbus_string_starts_with_c_str (path, DBUS_PREFIX "/"))
1454 {
1455 /* Replace DBUS_PREFIX "/" with runtime_prefix.
1456 * Note unusual calling convention: source is first, then dest */
1458 &runtime_prefix, 0, _dbus_string_get_length (&runtime_prefix),
1459 path, 0, strlen (DBUS_PREFIX) + 1))
1460 {
1461 _dbus_string_free (&runtime_prefix);
1462 return FALSE;
1463 }
1464 }
1465
1466 /* Somehow, in some situations, backslashes get collapsed in the string.
1467 * Since windows C library accepts both forward and backslashes as
1468 * path separators, convert all backslashes to forward slashes.
1469 */
1470
1471 for (i = 0; i < _dbus_string_get_length (path); i++)
1472 {
1473 if (_dbus_string_get_byte (path, i) == '\\')
1474 _dbus_string_set_byte (path, i, '/');
1475 }
1476
1477 _dbus_string_free (&runtime_prefix);
1478 return TRUE;
1479#endif
1480}
1481
1482#define DBUS_STANDARD_SESSION_SERVICEDIR "/dbus-1/services"
1483#define DBUS_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services"
1484
1494 DBusError *error)
1495{
1496 /* Not an error, we just don't have transient session services on Windows */
1497 return TRUE;
1498}
1499
1518{
1519 const char *common_progs;
1520 DBusString servicedir_path;
1521
1522 if (!_dbus_string_init (&servicedir_path))
1523 return FALSE;
1524
1525#ifdef DBUS_WINCE
1526 {
1527 /* On Windows CE, we adjust datadir dynamically to installation location. */
1528 const char *data_dir = _dbus_getenv ("DBUS_DATADIR");
1529
1530 if (data_dir != NULL)
1531 {
1532 if (!_dbus_string_append (&servicedir_path, data_dir))
1533 goto oom;
1534
1535 if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
1536 goto oom;
1537 }
1538 }
1539#else
1540 {
1541 DBusString p;
1542
1543 if (!_dbus_string_init (&p))
1544 goto oom;
1545
1546 /* DBUS_DATADIR is assumed to be absolute; the build systems should
1547 * ensure that. */
1548 if (!_dbus_string_append (&p, DBUS_DATADIR) ||
1550 {
1551 _dbus_string_free (&p);
1552 goto oom;
1553 }
1554
1555 if (!_dbus_string_append (&servicedir_path,
1557 {
1558 _dbus_string_free (&p);
1559 goto oom;
1560 }
1561
1562 _dbus_string_free (&p);
1563 }
1564
1565 if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
1566 goto oom;
1567#endif
1568
1569 common_progs = _dbus_getenv ("CommonProgramFiles");
1570
1571 if (common_progs != NULL)
1572 {
1573 if (!_dbus_string_append (&servicedir_path, common_progs))
1574 goto oom;
1575
1576 if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
1577 goto oom;
1578 }
1579
1580 if (!_dbus_split_paths_and_append (&servicedir_path,
1581 DBUS_STANDARD_SESSION_SERVICEDIR,
1582 dirs))
1583 goto oom;
1584
1585 _dbus_string_free (&servicedir_path);
1586 return TRUE;
1587
1588 oom:
1589 _dbus_string_free (&servicedir_path);
1590 return FALSE;
1591}
1592
1613{
1614 *dirs = NULL;
1615 return TRUE;
1616}
1617
1618static dbus_bool_t
1619_dbus_get_config_file_name (DBusString *str,
1620 const char *basename)
1621{
1622 DBusString tmp;
1623
1624 if (!_dbus_string_append (str, DBUS_DATADIR) ||
1626 return FALSE;
1627
1628 _dbus_string_init_const (&tmp, "dbus-1");
1629
1630 if (!_dbus_concat_dir_and_file (str, &tmp))
1631 return FALSE;
1632
1633 _dbus_string_init_const (&tmp, basename);
1634
1635 if (!_dbus_concat_dir_and_file (str, &tmp))
1636 return FALSE;
1637
1638 return TRUE;
1639}
1640
1651{
1653
1654 return _dbus_get_config_file_name(str, "system.conf");
1655}
1656
1665{
1667
1668 return _dbus_get_config_file_name(str, "session.conf");
1669}
1670
1671void
1673{
1674}
1675
1676void
1678{
1679}
1680
1681void
1683{
1684}
1685
1686void
1688{
1689}
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
Definition: dbus-errors.c:356
dbus_bool_t dbus_error_is_set(const DBusError *error)
Checks whether an error occurred (the error is set).
Definition: dbus-errors.c:331
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
const char * _dbus_error_from_system_errno(void)
Converts the current system errno value into a DBusError name.
Definition: dbus-sysdeps.c:693
const char * _dbus_strerror_from_errno(void)
Get error message from errno.
Definition: dbus-sysdeps.c:760
#define NULL
A null pointer, defined appropriately for C or C++.
#define TRUE
Expands to "1".
#define FALSE
Expands to "0".
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
Definition: dbus-memory.c:694
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
Definition: dbus-memory.h:60
#define DBUS_ERROR_NOT_SUPPORTED
Requested operation isn't supported (like ENOSYS on UNIX).
#define DBUS_ERROR_FAILED
A generic error; "something went wrong" - see the error message for more.
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
dbus_bool_t _dbus_string_set_length(DBusString *str, int length)
Sets the length of a string.
Definition: dbus-string.c:847
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
Definition: dbus-string.c:980
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
Definition: dbus-string.c:182
void _dbus_string_init_const(DBusString *str, const char *value)
Initializes a constant string.
Definition: dbus-string.c:197
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_string_append_int(DBusString *str, long value)
Appends an integer to a DBusString.
Definition: dbus-sysdeps.c:365
dbus_bool_t _dbus_parse_unix_user_from_config(const DBusString *username, dbus_uid_t *uid_p)
Parse a UNIX user from the bus config file.
dbus_bool_t _dbus_string_ends_with_c_str(const DBusString *a, const char *c_str)
Returns whether a string ends with the given suffix.
dbus_bool_t _dbus_string_starts_with_c_str(const DBusString *a, const char *c_str)
Checks whether a string starts with the given C string.
Definition: dbus-string.c:2250
dbus_bool_t _dbus_string_init_from_string(DBusString *str, const DBusString *from)
Initializes a string from another string.
Definition: dbus-string.c:254
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(), and fills it with the same contents as #_DBUS_STRING_I...
Definition: dbus-string.c:278
dbus_bool_t _dbus_unix_user_is_process_owner(dbus_uid_t uid)
Checks to see if the UNIX user ID matches the UID of the process.
dbus_bool_t _dbus_string_find_byte_backward(const DBusString *str, int start, unsigned char byte, int *found)
Find the given byte scanning backward from the given start.
dbus_bool_t _dbus_windows_user_is_process_owner(const char *windows_sid)
Checks to see if the Windows user SID matches the owner of the process.
dbus_bool_t _dbus_parse_unix_group_from_config(const DBusString *groupname, dbus_gid_t *gid_p)
Parse a UNIX group from the bus config file.
dbus_bool_t _dbus_unix_groups_from_uid(dbus_uid_t uid, dbus_gid_t **group_ids, int *n_group_ids, DBusError *error)
Gets all groups corresponding to the given UNIX user ID.
int _dbus_string_get_length(const DBusString *str)
Gets the length of a string (not including nul termination).
Definition: dbus-string.c:784
void _dbus_string_set_byte(DBusString *str, int i, unsigned char byte)
Sets the value of the byte at the given position.
Definition: dbus-string.c:583
const char * _dbus_string_get_const_data(const DBusString *str)
Gets the raw character buffer from a const string.
Definition: dbus-string.c:513
unsigned char _dbus_string_get_byte(const DBusString *str, int start)
Gets the byte at the given position.
Definition: dbus-string.c:607
dbus_bool_t _dbus_unix_user_is_at_console(dbus_uid_t uid, DBusError *error)
Checks to see if the UNIX user ID is at the console.
dbus_bool_t _dbus_string_copy_len(const DBusString *source, int start, int len, DBusString *dest, int insert_at)
Like _dbus_string_copy(), but can copy a segment from the middle of the source string.
Definition: dbus-string.c:1437
dbus_bool_t _dbus_string_get_dirname(const DBusString *filename, DBusString *dirname)
Get the directory name from a complete filename.
dbus_bool_t _dbus_string_replace_len(const DBusString *source, int start, int len, DBusString *dest, int replace_at, int replace_len)
Replaces a segment of dest string with a segment of source string.
Definition: dbus-string.c:1466
dbus_bool_t _dbus_stat(const DBusString *filename, DBusStat *statbuf, DBusError *error)
stat() wrapper.
dbus_bool_t _dbus_get_standard_session_servicedirs(DBusList **dirs)
Returns the standard directories for a session bus to look for service activation files.
void _dbus_daemon_report_ready(void)
Report to a service manager that the daemon calling this function is ready for use.
dbus_bool_t _dbus_write_pid_to_file_and_pipe(const DBusString *pidfile, DBusPipe *print_pid_pipe, dbus_pid_t pid_to_write, DBusError *error)
Writes the given pid_to_write to a pidfile (if non-NULL) and/or to a pipe (if non-NULL).
void _dbus_directory_close(DBusDirIter *iter)
Closes a directory iteration.
unsigned long dbus_uid_t
A user ID.
Definition: dbus-sysdeps.h:141
dbus_bool_t _dbus_get_session_config_file(DBusString *str)
Get the absolute path of the session.conf file.
unsigned long dbus_pid_t
A process ID.
Definition: dbus-sysdeps.h:139
void _dbus_daemon_report_reloading(void)
Report to a service manager that the daemon calling this function is reloading configuration.
unsigned long dbus_gid_t
A group ID.
Definition: dbus-sysdeps.h:143
dbus_bool_t _dbus_command_for_pid(unsigned long pid, DBusString *str, int max_len, DBusError *error)
Get a printable string describing the command used to execute the process with pid.
dbus_bool_t _dbus_get_system_config_file(DBusString *str)
Get the absolute path of the system.conf file (there is no system bus on Windows so this can just ret...
DBusDirIter * _dbus_directory_open(const DBusString *filename, DBusError *error)
Open a directory to iterate over.
dbus_bool_t _dbus_set_up_transient_session_servicedirs(DBusList **dirs, DBusError *error)
Returns the standard directories for a session bus to look for transient service activation files.
#define DBUS_UID_UNSET
an invalid UID used to represent an uninitialized dbus_uid_t field
Definition: dbus-sysdeps.h:148
dbus_bool_t _dbus_verify_daemon_user(const char *user)
Verify that after the fork we can successfully change to this user.
const char * _dbus_getenv(const char *varname)
Wrapper for getenv().
Definition: dbus-sysdeps.c:197
dbus_bool_t _dbus_get_standard_system_servicedirs(DBusList **dirs)
Returns the standard directories for a system bus to look for service activation files.
void _dbus_daemon_report_reloaded(void)
Report to a service manager that the daemon calling this function is reloading configuration.
#define DBUS_GID_UNSET
an invalid GID used to represent an uninitialized dbus_gid_t field
Definition: dbus-sysdeps.h:150
dbus_bool_t _dbus_change_to_daemon_user(const char *user, DBusError *error)
Changes the user and group the bus is running as.
void _dbus_daemon_report_stopping(void)
Report to a service manager that the daemon calling this function is shutting down.
dbus_bool_t _dbus_directory_get_next_file(DBusDirIter *iter, DBusString *filename, DBusError *error)
Get next file in the directory.
dbus_bool_t _dbus_concat_dir_and_file(DBusString *dir, const DBusString *next_component)
Appends the given filename to the given directory.
dbus_bool_t _dbus_become_daemon(const DBusString *pidfile, DBusPipe *print_pid_pipe, DBusError *error, dbus_bool_t keep_umask)
Does the chdir, fork, setsid, etc.
dbus_bool_t _dbus_split_paths_and_append(DBusString *dirs, const char *suffix, DBusList **dir_list)
Split paths into a list of char strings.
Definition: dbus-sysdeps.c:238
dbus_bool_t _dbus_replace_install_prefix(DBusString *path)
Replace the DBUS_PREFIX in the given path, in-place, by the current D-Bus installation directory.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:37
#define DBUS_INT64_CONSTANT(val)
Declare a 64-bit signed integer constant.
_DBUS_GNUC_EXTENSION typedef long dbus_int64_t
A 64-bit signed integer.
Internals of directory iterator.
Object representing an exception.
Definition: dbus-errors.h:51
A node in a linked list.
Definition: dbus-list.h:37
Portable struct with stat() results.
Definition: dbus-sysdeps.h:569
unsigned long nlink
Number of hard links.
Definition: dbus-sysdeps.h:571
unsigned long size
Size of file.
Definition: dbus-sysdeps.h:574
dbus_uid_t uid
User owning file.
Definition: dbus-sysdeps.h:572
unsigned long mode
File mode.
Definition: dbus-sysdeps.h:570
dbus_gid_t gid
Group owning file.
Definition: dbus-sysdeps.h:573
unsigned long atime
Access time.
Definition: dbus-sysdeps.h:575
unsigned long ctime
Creation time.
Definition: dbus-sysdeps.h:577
unsigned long mtime
Modify time.
Definition: dbus-sysdeps.h:576