D-Bus: dbus-sysdeps-util-win.c Source File

D-Bus 1.14.10

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