Update the windows implementation of logging functions
[platform/upstream/dbus.git] / dbus / 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 #define STRSAFE_NO_DEPRECATE
26
27 #include "dbus-sysdeps.h"
28 #include "dbus-internals.h"
29 #include "dbus-protocol.h"
30 #include "dbus-string.h"
31 #include "dbus-sysdeps.h"
32 #include "dbus-sysdeps-win.h"
33 #include "dbus-sockets-win.h"
34 #include "dbus-memory.h"
35
36 #include <io.h>
37 #include <sys/stat.h>
38 #include <aclapi.h>
39 #include <winsock2.h>
40
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <fcntl.h>
44 #include <errno.h>
45 #include <winsock2.h>   // WSA error codes
46
47 /**
48  * Does the chdir, fork, setsid, etc. to become a daemon process.
49  *
50  * @param pidfile #NULL, or pidfile to create
51  * @param print_pid_fd file descriptor to print daemon's pid to, or -1 for none
52  * @param error return location for errors
53  * @param keep_umask #TRUE to keep the original umask
54  * @returns #FALSE on failure
55  */
56 dbus_bool_t
57 _dbus_become_daemon (const DBusString *pidfile,
58                      DBusPipe         *print_pid_pipe,
59                      DBusError        *error,
60                      dbus_bool_t       keep_umask)
61 {
62   return TRUE;
63 }
64
65 /**
66  * Creates a file containing the process ID.
67  *
68  * @param filename the filename to write to
69  * @param pid our process ID
70  * @param error return location for errors
71  * @returns #FALSE on failure
72  */
73 static dbus_bool_t
74 _dbus_write_pid_file (const DBusString *filename,
75                       unsigned long     pid,
76                       DBusError        *error)
77 {
78   const char *cfilename;
79   int fd;
80   FILE *f;
81
82   cfilename = _dbus_string_get_const_data (filename);
83   
84   fd = _open (cfilename, O_WRONLY|O_CREAT|O_EXCL|O_BINARY, 0644);
85   
86   if (fd < 0)
87     {
88       dbus_set_error (error, _dbus_error_from_errno (errno),
89                       "Failed to open \"%s\": %s", cfilename,
90                       strerror (errno));
91       return FALSE;
92     }
93
94   if ((f = fdopen (fd, "w")) == NULL)
95     {
96       dbus_set_error (error, _dbus_error_from_errno (errno),
97                       "Failed to fdopen fd %d: %s", fd, strerror (errno));
98       _close (fd);
99       return FALSE;
100     }
101
102   if (fprintf (f, "%lu\n", pid) < 0)
103     {
104       dbus_set_error (error, _dbus_error_from_errno (errno),
105                       "Failed to write to \"%s\": %s", cfilename,
106                       strerror (errno));
107
108       fclose (f);
109       return FALSE;
110     }
111
112   if (fclose (f) == EOF)
113     {
114       dbus_set_error (error, _dbus_error_from_errno (errno),
115                       "Failed to close \"%s\": %s", cfilename,
116                       strerror (errno));
117       return FALSE;
118     }
119
120   return TRUE;
121 }
122
123 /**
124  * Writes the given pid_to_write to a pidfile (if non-NULL) and/or to a
125  * pipe (if non-NULL). Does nothing if pidfile and print_pid_pipe are both
126  * NULL.
127  *
128  * @param pidfile the file to write to or #NULL
129  * @param print_pid_pipe the pipe to write to or #NULL
130  * @param pid_to_write the pid to write out
131  * @param error error on failure
132  * @returns FALSE if error is set
133  */
134 dbus_bool_t
135 _dbus_write_pid_to_file_and_pipe (const DBusString *pidfile,
136                                   DBusPipe         *print_pid_pipe,
137                                   dbus_pid_t        pid_to_write,
138                                   DBusError        *error)
139 {
140   if (pidfile)
141     {
142       _dbus_verbose ("writing pid file %s\n", _dbus_string_get_const_data (pidfile));
143       if (!_dbus_write_pid_file (pidfile,
144                                  pid_to_write,
145                                  error))
146         {
147           _dbus_verbose ("pid file write failed\n");
148           _DBUS_ASSERT_ERROR_IS_SET(error);
149           return FALSE;
150         }
151     }
152   else
153     {
154       _dbus_verbose ("No pid file requested\n");
155     }
156
157   if (print_pid_pipe != NULL && _dbus_pipe_is_valid (print_pid_pipe))
158     {
159       DBusString pid;
160       int bytes;
161
162       _dbus_verbose ("writing our pid to pipe %d\n", print_pid_pipe->fd_or_handle);
163
164       if (!_dbus_string_init (&pid))
165         {
166           _DBUS_SET_OOM (error);
167           return FALSE;
168         }
169
170       if (!_dbus_string_append_int (&pid, pid_to_write) ||
171           !_dbus_string_append (&pid, "\n"))
172         {
173           _dbus_string_free (&pid);
174           _DBUS_SET_OOM (error);
175           return FALSE;
176         }
177
178       bytes = _dbus_string_get_length (&pid);
179       if (_dbus_pipe_write (print_pid_pipe, &pid, 0, bytes, error) != bytes)
180         {
181           /* _dbus_pipe_write sets error only on failure, not short write */
182           if (error != NULL && !dbus_error_is_set(error))
183             {
184               dbus_set_error (error, DBUS_ERROR_FAILED,
185                               "Printing message bus PID: did not write enough bytes\n");
186             }
187           _dbus_string_free (&pid);
188           return FALSE;
189         }
190
191       _dbus_string_free (&pid);
192     }
193   else
194     {
195       _dbus_verbose ("No pid pipe to write to\n");
196     }
197
198   return TRUE;
199 }
200
201 /**
202  * Verify that after the fork we can successfully change to this user.
203  *
204  * @param user the username given in the daemon configuration
205  * @returns #TRUE if username is valid
206  */
207 dbus_bool_t
208 _dbus_verify_daemon_user (const char *user)
209 {
210   return TRUE;
211 }
212
213 /**
214  * Changes the user and group the bus is running as.
215  *
216  * @param user the user to become
217  * @param error return location for errors
218  * @returns #FALSE on failure
219  */
220 dbus_bool_t
221 _dbus_change_to_daemon_user  (const char    *user,
222                               DBusError     *error)
223 {
224   return TRUE;
225 }
226
227 void
228 _dbus_init_system_log (void)
229 {
230     // FIXME!
231 }
232
233 /**
234  * Log a message to the system log file (e.g. syslog on Unix).
235  *
236  * @param severity a severity value
237  * @param msg a printf-style format string
238  * @param args arguments for the format string
239  *
240  */
241 void
242 _dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...)
243 {
244   va_list args;
245
246   va_start (args, msg);
247
248   _dbus_system_logv (severity, msg, args);
249
250   va_end (args);
251 }
252
253 /**
254  * Log a message to the system log file (e.g. syslog on Unix).
255  *
256  * @param severity a severity value
257  * @param msg a printf-style format string
258  * @param args arguments for the format string
259  *
260  * If the FATAL severity is given, this function will terminate the program
261  * with an error code.
262  */
263 void
264 _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args)
265 {
266     // FIXME!
267 }
268
269 /** Installs a signal handler
270  *
271  * @param sig the signal to handle
272  * @param handler the handler
273  */
274 void
275 _dbus_set_signal_handler (int               sig,
276                           DBusSignalHandler handler)
277 {
278   _dbus_verbose ("_dbus_set_signal_handler() has to be implemented\n");
279 }
280
281 /**
282  * stat() wrapper.
283  *
284  * @param filename the filename to stat
285  * @param statbuf the stat info to fill in
286  * @param error return location for error
287  * @returns #FALSE if error was set
288  */
289 dbus_bool_t
290 _dbus_stat(const DBusString *filename,
291            DBusStat         *statbuf,
292            DBusError        *error)
293 {
294 #ifdef DBUS_WINCE
295         return TRUE;
296         //TODO
297 #else
298   const char *filename_c;
299   WIN32_FILE_ATTRIBUTE_DATA wfad;
300   char *lastdot;
301   DWORD rc;
302   PSID owner_sid, group_sid;
303   PSECURITY_DESCRIPTOR sd;
304
305   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
306
307   filename_c = _dbus_string_get_const_data (filename);
308
309   if (!GetFileAttributesEx (filename_c, GetFileExInfoStandard, &wfad))
310     {
311       _dbus_win_set_error_from_win_error (error, GetLastError ());
312       return FALSE;
313     }
314
315   if (wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
316     statbuf->mode = _S_IFDIR;
317   else
318     statbuf->mode = _S_IFREG;
319
320   statbuf->mode |= _S_IREAD;
321   if (wfad.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
322     statbuf->mode |= _S_IWRITE;
323
324   lastdot = strrchr (filename_c, '.');
325   if (lastdot && stricmp (lastdot, ".exe") == 0)
326     statbuf->mode |= _S_IEXEC;
327
328   statbuf->mode |= (statbuf->mode & 0700) >> 3;
329   statbuf->mode |= (statbuf->mode & 0700) >> 6;
330
331   statbuf->nlink = 1;
332
333   sd = NULL;
334   rc = GetNamedSecurityInfo ((char *) filename_c, SE_FILE_OBJECT,
335                              OWNER_SECURITY_INFORMATION |
336                              GROUP_SECURITY_INFORMATION,
337                              &owner_sid, &group_sid,
338                              NULL, NULL,
339                              &sd);
340   if (rc != ERROR_SUCCESS)
341     {
342       _dbus_win_set_error_from_win_error (error, rc);
343       if (sd != NULL)
344         LocalFree (sd);
345       return FALSE;
346     }
347
348 #ifdef ENABLE_UID_TO_SID
349   /* FIXME */
350   statbuf->uid = _dbus_win_sid_to_uid_t (owner_sid);
351   statbuf->gid = _dbus_win_sid_to_uid_t (group_sid);
352 #endif
353
354   LocalFree (sd);
355
356   statbuf->size = ((dbus_int64_t) wfad.nFileSizeHigh << 32) + wfad.nFileSizeLow;
357
358   statbuf->atime =
359     (((dbus_int64_t) wfad.ftLastAccessTime.dwHighDateTime << 32) +
360      wfad.ftLastAccessTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
361
362   statbuf->mtime =
363     (((dbus_int64_t) wfad.ftLastWriteTime.dwHighDateTime << 32) +
364      wfad.ftLastWriteTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
365
366   statbuf->ctime =
367     (((dbus_int64_t) wfad.ftCreationTime.dwHighDateTime << 32) +
368      wfad.ftCreationTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
369
370   return TRUE;
371 #endif //DBUS_WINCE
372 }
373
374
375 #ifdef HAVE_DIRENT_H
376
377 // mingw ships with dirent.h
378 #include <dirent.h>
379 #define _dbus_opendir opendir
380 #define _dbus_readdir readdir
381 #define _dbus_closedir closedir
382
383 #else
384
385 #ifdef HAVE_IO_H
386 #include <io.h> // win32 file functions
387 #endif
388
389 #include <sys/types.h>
390 #include <stdlib.h>
391
392 /* This file is part of the KDE project
393 Copyright (C) 2000 Werner Almesberger
394
395 libc/sys/linux/sys/dirent.h - Directory entry as returned by readdir
396
397 This program is free software; you can redistribute it and/or
398 modify it under the terms of the GNU Library General Public
399 License as published by the Free Software Foundation; either
400 version 2 of the License, or (at your option) any later version.
401
402 This program is distributed in the hope that it will be useful,
403 but WITHOUT ANY WARRANTY; without even the implied warranty of
404 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
405 Library General Public License for more details.
406
407 You should have received a copy of the GNU Library General Public License
408 along with this program; see the file COPYING.  If not, write to
409 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
410 Boston, MA 02110-1301, USA.
411 */
412 #define HAVE_NO_D_NAMLEN        /* no struct dirent->d_namlen */
413 #define HAVE_DD_LOCK            /* have locking mechanism */
414
415 #define MAXNAMLEN 255           /* sizeof(struct dirent.d_name)-1 */
416
417 #define __dirfd(dir) (dir)->dd_fd
418
419 /* struct dirent - same as Unix */
420 struct dirent
421   {
422     long d_ino;                    /* inode (always 1 in WIN32) */
423     off_t d_off;                /* offset to this dirent */
424     unsigned short d_reclen;    /* length of d_name */
425     char d_name[_MAX_FNAME+1];    /* filename (null terminated) */
426   };
427
428 /* typedef DIR - not the same as Unix */
429 typedef struct
430   {
431     long handle;                /* _findfirst/_findnext handle */
432     short offset;                /* offset into directory */
433     short finished;             /* 1 if there are not more files */
434     struct _finddata_t fileinfo;  /* from _findfirst/_findnext */
435     char *dir;                  /* the dir we are reading */
436     struct dirent dent;         /* the dirent to return */
437   }
438 DIR;
439
440 /**********************************************************************
441 * Implement dirent-style opendir/readdir/closedir on Window 95/NT
442 *
443 * Functions defined are opendir(), readdir() and closedir() with the
444 * same prototypes as the normal dirent.h implementation.
445 *
446 * Does not implement telldir(), seekdir(), rewinddir() or scandir().
447 * The dirent struct is compatible with Unix, except that d_ino is
448 * always 1 and d_off is made up as we go along.
449 *
450 * The DIR typedef is not compatible with Unix.
451 **********************************************************************/
452
453 static DIR * _dbus_opendir(const char *dir)
454 {
455   DIR *dp;
456   char *filespec;
457   long handle;
458   int index;
459
460   filespec = malloc(strlen(dir) + 2 + 1);
461   strcpy(filespec, dir);
462   index = strlen(filespec) - 1;
463   if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\'))
464     filespec[index] = '\0';
465   strcat(filespec, "\\*");
466
467   dp = (DIR *)malloc(sizeof(DIR));
468   dp->offset = 0;
469   dp->finished = 0;
470   dp->dir = strdup(dir);
471
472   if ((handle = _findfirst(filespec, &(dp->fileinfo))) < 0)
473     {
474       if (errno == ENOENT)
475         dp->finished = 1;
476       else
477         return NULL;
478     }
479
480   dp->handle = handle;
481   free(filespec);
482
483   return dp;
484 }
485
486 static struct dirent * _dbus_readdir(DIR *dp)
487   {
488     if (!dp || dp->finished)
489       return NULL;
490
491     if (dp->offset != 0)
492       {
493         if (_findnext(dp->handle, &(dp->fileinfo)) < 0)
494           {
495             dp->finished = 1;
496             errno = 0;
497             return NULL;
498           }
499       }
500     dp->offset++;
501
502     strncpy(dp->dent.d_name, dp->fileinfo.name, _MAX_FNAME);
503     dp->dent.d_ino = 1;
504     dp->dent.d_reclen = strlen(dp->dent.d_name);
505     dp->dent.d_off = dp->offset;
506
507     return &(dp->dent);
508   }
509
510
511 static int _dbus_closedir(DIR *dp)
512 {
513   if (!dp)
514     return 0;
515   _findclose(dp->handle);
516   if (dp->dir)
517     free(dp->dir);
518   if (dp)
519     free(dp);
520
521   return 0;
522 }
523
524 #endif //#ifdef HAVE_DIRENT_H
525
526 /**
527  * Internals of directory iterator
528  */
529 struct DBusDirIter
530   {
531     DIR *d; /**< The DIR* from opendir() */
532
533   };
534
535 /**
536  * Open a directory to iterate over.
537  *
538  * @param filename the directory name
539  * @param error exception return object or #NULL
540  * @returns new iterator, or #NULL on error
541  */
542 DBusDirIter*
543 _dbus_directory_open (const DBusString *filename,
544                       DBusError        *error)
545 {
546   DIR *d;
547   DBusDirIter *iter;
548   const char *filename_c;
549
550   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
551
552   filename_c = _dbus_string_get_const_data (filename);
553
554   d = _dbus_opendir (filename_c);
555   if (d == NULL)
556     {
557       dbus_set_error (error, _dbus_error_from_errno (errno),
558                       "Failed to read directory \"%s\": %s",
559                       filename_c,
560                       _dbus_strerror (errno));
561       return NULL;
562     }
563   iter = dbus_new0 (DBusDirIter, 1);
564   if (iter == NULL)
565     {
566       _dbus_closedir (d);
567       dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
568                       "Could not allocate memory for directory iterator");
569       return NULL;
570     }
571
572   iter->d = d;
573
574   return iter;
575 }
576
577 /**
578  * Get next file in the directory. Will not return "." or ".."  on
579  * UNIX. If an error occurs, the contents of "filename" are
580  * undefined. The error is never set if the function succeeds.
581  *
582  * @todo for thread safety, I think we have to use
583  * readdir_r(). (GLib has the same issue, should file a bug.)
584  *
585  * @param iter the iterator
586  * @param filename string to be set to the next file in the dir
587  * @param error return location for error
588  * @returns #TRUE if filename was filled in with a new filename
589  */
590 dbus_bool_t
591 _dbus_directory_get_next_file (DBusDirIter      *iter,
592                                DBusString       *filename,
593                                DBusError        *error)
594 {
595   struct dirent *ent;
596
597   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
598
599 again:
600   errno = 0;
601   ent = _dbus_readdir (iter->d);
602   if (ent == NULL)
603     {
604       if (errno != 0)
605         dbus_set_error (error,
606                         _dbus_error_from_errno (errno),
607                         "%s", _dbus_strerror (errno));
608       return FALSE;
609     }
610   else if (ent->d_name[0] == '.' &&
611            (ent->d_name[1] == '\0' ||
612             (ent->d_name[1] == '.' && ent->d_name[2] == '\0')))
613     goto again;
614   else
615     {
616       _dbus_string_set_length (filename, 0);
617       if (!_dbus_string_append (filename, ent->d_name))
618         {
619           dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
620                           "No memory to read directory entry");
621           return FALSE;
622         }
623       else
624         return TRUE;
625     }
626 }
627
628 /**
629  * Closes a directory iteration.
630  */
631 void
632 _dbus_directory_close (DBusDirIter *iter)
633 {
634   _dbus_closedir (iter->d);
635   dbus_free (iter);
636 }
637
638 /**
639  * Checks whether the filename is an absolute path
640  *
641  * @param filename the filename
642  * @returns #TRUE if an absolute path
643  */
644 dbus_bool_t
645 _dbus_path_is_absolute (const DBusString *filename)
646 {
647   if (_dbus_string_get_length (filename) > 0)
648     return _dbus_string_get_byte (filename, 1) == ':'
649            || _dbus_string_get_byte (filename, 0) == '\\'
650            || _dbus_string_get_byte (filename, 0) == '/';
651   else
652     return FALSE;
653 }
654
655 /** @} */ /* End of DBusInternalsUtils functions */
656
657 /**
658  * @addtogroup DBusString
659  *
660  * @{
661  */
662 /**
663  * Get the directory name from a complete filename
664  * @param filename the filename
665  * @param dirname string to append directory name to
666  * @returns #FALSE if no memory
667  */
668 dbus_bool_t
669 _dbus_string_get_dirname(const DBusString *filename,
670                          DBusString       *dirname)
671 {
672   int sep;
673
674   _dbus_assert (filename != dirname);
675   _dbus_assert (filename != NULL);
676   _dbus_assert (dirname != NULL);
677
678   /* Ignore any separators on the end */
679   sep = _dbus_string_get_length (filename);
680   if (sep == 0)
681     return _dbus_string_append (dirname, "."); /* empty string passed in */
682
683   while (sep > 0 &&
684          (_dbus_string_get_byte (filename, sep - 1) == '/' ||
685           _dbus_string_get_byte (filename, sep - 1) == '\\'))
686     --sep;
687
688   _dbus_assert (sep >= 0);
689
690   if (sep == 0 ||
691       (sep == 2 &&
692        _dbus_string_get_byte (filename, 1) == ':' &&
693        isalpha (_dbus_string_get_byte (filename, 0))))
694     return _dbus_string_copy_len (filename, 0, sep + 1,
695                                   dirname, _dbus_string_get_length (dirname));
696
697   {
698     int sep1, sep2;
699     _dbus_string_find_byte_backward (filename, sep, '/', &sep1);
700     _dbus_string_find_byte_backward (filename, sep, '\\', &sep2);
701
702     sep = MAX (sep1, sep2);
703   }
704   if (sep < 0)
705     return _dbus_string_append (dirname, ".");
706
707   while (sep > 0 &&
708          (_dbus_string_get_byte (filename, sep - 1) == '/' ||
709           _dbus_string_get_byte (filename, sep - 1) == '\\'))
710     --sep;
711
712   _dbus_assert (sep >= 0);
713
714   if ((sep == 0 ||
715        (sep == 2 &&
716         _dbus_string_get_byte (filename, 1) == ':' &&
717         isalpha (_dbus_string_get_byte (filename, 0))))
718       &&
719       (_dbus_string_get_byte (filename, sep) == '/' ||
720        _dbus_string_get_byte (filename, sep) == '\\'))
721     return _dbus_string_copy_len (filename, 0, sep + 1,
722                                   dirname, _dbus_string_get_length (dirname));
723   else
724     return _dbus_string_copy_len (filename, 0, sep - 0,
725                                   dirname, _dbus_string_get_length (dirname));
726 }
727
728
729 /**
730  * Checks to see if the UNIX user ID matches the UID of
731  * the process. Should always return #FALSE on Windows.
732  *
733  * @param uid the UNIX user ID
734  * @returns #TRUE if this uid owns the process.
735  */
736 dbus_bool_t
737 _dbus_unix_user_is_process_owner (dbus_uid_t uid)
738 {
739   return FALSE;
740 }
741
742 dbus_bool_t _dbus_windows_user_is_process_owner (const char *windows_sid)
743 {
744   return TRUE;
745 }
746
747 /*=====================================================================
748   unix emulation functions - should be removed sometime in the future
749  =====================================================================*/
750
751 /**
752  * Checks to see if the UNIX user ID is at the console.
753  * Should always fail on Windows (set the error to
754  * #DBUS_ERROR_NOT_SUPPORTED).
755  *
756  * @param uid UID of person to check 
757  * @param error return location for errors
758  * @returns #TRUE if the UID is the same as the console user and there are no errors
759  */
760 dbus_bool_t
761 _dbus_unix_user_is_at_console (dbus_uid_t         uid,
762                                DBusError         *error)
763 {
764   dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
765                   "UNIX user IDs not supported on Windows\n");
766   return FALSE;
767 }
768
769
770 /**
771  * Parse a UNIX group from the bus config file. On Windows, this should
772  * simply always fail (just return #FALSE).
773  *
774  * @param groupname the groupname text
775  * @param gid_p place to return the gid
776  * @returns #TRUE on success
777  */
778 dbus_bool_t
779 _dbus_parse_unix_group_from_config (const DBusString  *groupname,
780                                     dbus_gid_t        *gid_p)
781 {
782   return FALSE;
783 }
784
785 /**
786  * Parse a UNIX user from the bus config file. On Windows, this should
787  * simply always fail (just return #FALSE).
788  *
789  * @param username the username text
790  * @param uid_p place to return the uid
791  * @returns #TRUE on success
792  */
793 dbus_bool_t
794 _dbus_parse_unix_user_from_config (const DBusString  *username,
795                                    dbus_uid_t        *uid_p)
796 {
797   return FALSE;
798 }
799
800
801 /**
802  * Gets all groups corresponding to the given UNIX user ID. On UNIX,
803  * just calls _dbus_groups_from_uid(). On Windows, should always
804  * fail since we don't know any UNIX groups.
805  *
806  * @param uid the UID
807  * @param group_ids return location for array of group IDs
808  * @param n_group_ids return location for length of returned array
809  * @returns #TRUE if the UID existed and we got some credentials
810  */
811 dbus_bool_t
812 _dbus_unix_groups_from_uid (dbus_uid_t            uid,
813                             dbus_gid_t          **group_ids,
814                             int                  *n_group_ids)
815 {
816   return FALSE;
817 }
818
819
820
821 /** @} */ /* DBusString stuff */
822
823 /************************************************************************
824  
825  error handling
826  
827  ************************************************************************/
828
829
830
831
832
833 /* lan manager error codes */
834 const char*
835 _dbus_lm_strerror(int error_number)
836 {
837 #ifdef DBUS_WINCE
838   // TODO
839   return "unknown";
840 #else
841   const char *msg;
842   switch (error_number)
843     {
844     case NERR_NetNotStarted:
845       return "The workstation driver is not installed.";
846     case NERR_UnknownServer:
847       return "The server could not be located.";
848     case NERR_ShareMem:
849       return "An internal error occurred. The network cannot access a shared memory segment.";
850     case NERR_NoNetworkResource:
851       return "A network resource shortage occurred.";
852     case NERR_RemoteOnly:
853       return "This operation is not supported on workstations.";
854     case NERR_DevNotRedirected:
855       return "The device is not connected.";
856     case NERR_ServerNotStarted:
857       return "The Server service is not started.";
858     case NERR_ItemNotFound:
859       return "The queue is empty.";
860     case NERR_UnknownDevDir:
861       return "The device or directory does not exist.";
862     case NERR_RedirectedPath:
863       return "The operation is invalid on a redirected resource.";
864     case NERR_DuplicateShare:
865       return "The name has already been shared.";
866     case NERR_NoRoom:
867       return "The server is currently out of the requested resource.";
868     case NERR_TooManyItems:
869       return "Requested addition of items exceeds the maximum allowed.";
870     case NERR_InvalidMaxUsers:
871       return "The Peer service supports only two simultaneous users.";
872     case NERR_BufTooSmall:
873       return "The API return buffer is too small.";
874     case NERR_RemoteErr:
875       return "A remote API error occurred.";
876     case NERR_LanmanIniError:
877       return "An error occurred when opening or reading the configuration file.";
878     case NERR_NetworkError:
879       return "A general network error occurred.";
880     case NERR_WkstaInconsistentState:
881       return "The Workstation service is in an inconsistent state. Restart the computer before restarting the Workstation service.";
882     case NERR_WkstaNotStarted:
883       return "The Workstation service has not been started.";
884     case NERR_BrowserNotStarted:
885       return "The requested information is not available.";
886     case NERR_InternalError:
887       return "An internal error occurred.";
888     case NERR_BadTransactConfig:
889       return "The server is not configured for transactions.";
890     case NERR_InvalidAPI:
891       return "The requested API is not supported on the remote server.";
892     case NERR_BadEventName:
893       return "The event name is invalid.";
894     case NERR_DupNameReboot:
895       return "The computer name already exists on the network. Change it and restart the computer.";
896     case NERR_CfgCompNotFound:
897       return "The specified component could not be found in the configuration information.";
898     case NERR_CfgParamNotFound:
899       return "The specified parameter could not be found in the configuration information.";
900     case NERR_LineTooLong:
901       return "A line in the configuration file is too long.";
902     case NERR_QNotFound:
903       return "The printer does not exist.";
904     case NERR_JobNotFound:
905       return "The print job does not exist.";
906     case NERR_DestNotFound:
907       return "The printer destination cannot be found.";
908     case NERR_DestExists:
909       return "The printer destination already exists.";
910     case NERR_QExists:
911       return "The printer queue already exists.";
912     case NERR_QNoRoom:
913       return "No more printers can be added.";
914     case NERR_JobNoRoom:
915       return "No more print jobs can be added.";
916     case NERR_DestNoRoom:
917       return "No more printer destinations can be added.";
918     case NERR_DestIdle:
919       return "This printer destination is idle and cannot accept control operations.";
920     case NERR_DestInvalidOp:
921       return "This printer destination request contains an invalid control function.";
922     case NERR_ProcNoRespond:
923       return "The print processor is not responding.";
924     case NERR_SpoolerNotLoaded:
925       return "The spooler is not running.";
926     case NERR_DestInvalidState:
927       return "This operation cannot be performed on the print destination in its current state.";
928     case NERR_QInvalidState:
929       return "This operation cannot be performed on the printer queue in its current state.";
930     case NERR_JobInvalidState:
931       return "This operation cannot be performed on the print job in its current state.";
932     case NERR_SpoolNoMemory:
933       return "A spooler memory allocation failure occurred.";
934     case NERR_DriverNotFound:
935       return "The device driver does not exist.";
936     case NERR_DataTypeInvalid:
937       return "The data type is not supported by the print processor.";
938     case NERR_ProcNotFound:
939       return "The print processor is not installed.";
940     case NERR_ServiceTableLocked:
941       return "The service database is locked.";
942     case NERR_ServiceTableFull:
943       return "The service table is full.";
944     case NERR_ServiceInstalled:
945       return "The requested service has already been started.";
946     case NERR_ServiceEntryLocked:
947       return "The service does not respond to control actions.";
948     case NERR_ServiceNotInstalled:
949       return "The service has not been started.";
950     case NERR_BadServiceName:
951       return "The service name is invalid.";
952     case NERR_ServiceCtlTimeout:
953       return "The service is not responding to the control function.";
954     case NERR_ServiceCtlBusy:
955       return "The service control is busy.";
956     case NERR_BadServiceProgName:
957       return "The configuration file contains an invalid service program name.";
958     case NERR_ServiceNotCtrl:
959       return "The service could not be controlled in its present state.";
960     case NERR_ServiceKillProc:
961       return "The service ended abnormally.";
962     case NERR_ServiceCtlNotValid:
963       return "The requested pause or stop is not valid for this service.";
964     case NERR_NotInDispatchTbl:
965       return "The service control dispatcher could not find the service name in the dispatch table.";
966     case NERR_BadControlRecv:
967       return "The service control dispatcher pipe read failed.";
968     case NERR_ServiceNotStarting:
969       return "A thread for the new service could not be created.";
970     case NERR_AlreadyLoggedOn:
971       return "This workstation is already logged on to the local-area network.";
972     case NERR_NotLoggedOn:
973       return "The workstation is not logged on to the local-area network.";
974     case NERR_BadUsername:
975       return "The user name or group name parameter is invalid.";
976     case NERR_BadPassword:
977       return "The password parameter is invalid.";
978     case NERR_UnableToAddName_W:
979       return "@W The logon processor did not add the message alias.";
980     case NERR_UnableToAddName_F:
981       return "The logon processor did not add the message alias.";
982     case NERR_UnableToDelName_W:
983       return "@W The logoff processor did not delete the message alias.";
984     case NERR_UnableToDelName_F:
985       return "The logoff processor did not delete the message alias.";
986     case NERR_LogonsPaused:
987       return "Network logons are paused.";
988     case NERR_LogonServerConflict:
989       return "A centralized logon-server conflict occurred.";
990     case NERR_LogonNoUserPath:
991       return "The server is configured without a valid user path.";
992     case NERR_LogonScriptError:
993       return "An error occurred while loading or running the logon script.";
994     case NERR_StandaloneLogon:
995       return "The logon server was not specified. Your computer will be logged on as STANDALONE.";
996     case NERR_LogonServerNotFound:
997       return "The logon server could not be found.";
998     case NERR_LogonDomainExists:
999       return "There is already a logon domain for this computer.";
1000     case NERR_NonValidatedLogon:
1001       return "The logon server could not validate the logon.";
1002     case NERR_ACFNotFound:
1003       return "The security database could not be found.";
1004     case NERR_GroupNotFound:
1005       return "The group name could not be found.";
1006     case NERR_UserNotFound:
1007       return "The user name could not be found.";
1008     case NERR_ResourceNotFound:
1009       return "The resource name could not be found.";
1010     case NERR_GroupExists:
1011       return "The group already exists.";
1012     case NERR_UserExists:
1013       return "The user account already exists.";
1014     case NERR_ResourceExists:
1015       return "The resource permission list already exists.";
1016     case NERR_NotPrimary:
1017       return "This operation is only allowed on the primary domain controller of the domain.";
1018     case NERR_ACFNotLoaded:
1019       return "The security database has not been started.";
1020     case NERR_ACFNoRoom:
1021       return "There are too many names in the user accounts database.";
1022     case NERR_ACFFileIOFail:
1023       return "A disk I/O failure occurred.";
1024     case NERR_ACFTooManyLists:
1025       return "The limit of 64 entries per resource was exceeded.";
1026     case NERR_UserLogon:
1027       return "Deleting a user with a session is not allowed.";
1028     case NERR_ACFNoParent:
1029       return "The parent directory could not be located.";
1030     case NERR_CanNotGrowSegment:
1031       return "Unable to add to the security database session cache segment.";
1032     case NERR_SpeGroupOp:
1033       return "This operation is not allowed on this special group.";
1034     case NERR_NotInCache:
1035       return "This user is not cached in user accounts database session cache.";
1036     case NERR_UserInGroup:
1037       return "The user already belongs to this group.";
1038     case NERR_UserNotInGroup:
1039       return "The user does not belong to this group.";
1040     case NERR_AccountUndefined:
1041       return "This user account is undefined.";
1042     case NERR_AccountExpired:
1043       return "This user account has expired.";
1044     case NERR_InvalidWorkstation:
1045       return "The user is not allowed to log on from this workstation.";
1046     case NERR_InvalidLogonHours:
1047       return "The user is not allowed to log on at this time.";
1048     case NERR_PasswordExpired:
1049       return "The password of this user has expired.";
1050     case NERR_PasswordCantChange:
1051       return "The password of this user cannot change.";
1052     case NERR_PasswordHistConflict:
1053       return "This password cannot be used now.";
1054     case NERR_PasswordTooShort:
1055       return "The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements.";
1056     case NERR_PasswordTooRecent:
1057       return "The password of this user is too recent to change.";
1058     case NERR_InvalidDatabase:
1059       return "The security database is corrupted.";
1060     case NERR_DatabaseUpToDate:
1061       return "No updates are necessary to this replicant network/local security database.";
1062     case NERR_SyncRequired:
1063       return "This replicant database is outdated; synchronization is required.";
1064     case NERR_UseNotFound:
1065       return "The network connection could not be found.";
1066     case NERR_BadAsgType:
1067       return "This asg_type is invalid.";
1068     case NERR_DeviceIsShared:
1069       return "This device is currently being shared.";
1070     case NERR_NoComputerName:
1071       return "The computer name could not be added as a message alias. The name may already exist on the network.";
1072     case NERR_MsgAlreadyStarted:
1073       return "The Messenger service is already started.";
1074     case NERR_MsgInitFailed:
1075       return "The Messenger service failed to start.";
1076     case NERR_NameNotFound:
1077       return "The message alias could not be found on the network.";
1078     case NERR_AlreadyForwarded:
1079       return "This message alias has already been forwarded.";
1080     case NERR_AddForwarded:
1081       return "This message alias has been added but is still forwarded.";
1082     case NERR_AlreadyExists:
1083       return "This message alias already exists locally.";
1084     case NERR_TooManyNames:
1085       return "The maximum number of added message aliases has been exceeded.";
1086     case NERR_DelComputerName:
1087       return "The computer name could not be deleted.";
1088     case NERR_LocalForward:
1089       return "Messages cannot be forwarded back to the same workstation.";
1090     case NERR_GrpMsgProcessor:
1091       return "An error occurred in the domain message processor.";
1092     case NERR_PausedRemote:
1093       return "The message was sent, but the recipient has paused the Messenger service.";
1094     case NERR_BadReceive:
1095       return "The message was sent but not received.";
1096     case NERR_NameInUse:
1097       return "The message alias is currently in use. Try again later.";
1098     case NERR_MsgNotStarted:
1099       return "The Messenger service has not been started.";
1100     case NERR_NotLocalName:
1101       return "The name is not on the local computer.";
1102     case NERR_NoForwardName:
1103       return "The forwarded message alias could not be found on the network.";
1104     case NERR_RemoteFull:
1105       return "The message alias table on the remote station is full.";
1106     case NERR_NameNotForwarded:
1107       return "Messages for this alias are not currently being forwarded.";
1108     case NERR_TruncatedBroadcast:
1109       return "The broadcast message was truncated.";
1110     case NERR_InvalidDevice:
1111       return "This is an invalid device name.";
1112     case NERR_WriteFault:
1113       return "A write fault occurred.";
1114     case NERR_DuplicateName:
1115       return "A duplicate message alias exists on the network.";
1116     case NERR_DeleteLater:
1117       return "@W This message alias will be deleted later.";
1118     case NERR_IncompleteDel:
1119       return "The message alias was not successfully deleted from all networks.";
1120     case NERR_MultipleNets:
1121       return "This operation is not supported on computers with multiple networks.";
1122     case NERR_NetNameNotFound:
1123       return "This shared resource does not exist.";
1124     case NERR_DeviceNotShared:
1125       return "This device is not shared.";
1126     case NERR_ClientNameNotFound:
1127       return "A session does not exist with that computer name.";
1128     case NERR_FileIdNotFound:
1129       return "There is not an open file with that identification number.";
1130     case NERR_ExecFailure:
1131       return "A failure occurred when executing a remote administration command.";
1132     case NERR_TmpFile:
1133       return "A failure occurred when opening a remote temporary file.";
1134     case NERR_TooMuchData:
1135       return "The data returned from a remote administration command has been truncated to 64K.";
1136     case NERR_DeviceShareConflict:
1137       return "This device cannot be shared as both a spooled and a non-spooled resource.";
1138     case NERR_BrowserTableIncomplete:
1139       return "The information in the list of servers may be incorrect.";
1140     case NERR_NotLocalDomain:
1141       return "The computer is not active in this domain.";
1142 #ifdef NERR_IsDfsShare
1143
1144     case NERR_IsDfsShare:
1145       return "The share must be removed from the Distributed File System before it can be deleted.";
1146 #endif
1147
1148     case NERR_DevInvalidOpCode:
1149       return "The operation is invalid for this device.";
1150     case NERR_DevNotFound:
1151       return "This device cannot be shared.";
1152     case NERR_DevNotOpen:
1153       return "This device was not open.";
1154     case NERR_BadQueueDevString:
1155       return "This device name list is invalid.";
1156     case NERR_BadQueuePriority:
1157       return "The queue priority is invalid.";
1158     case NERR_NoCommDevs:
1159       return "There are no shared communication devices.";
1160     case NERR_QueueNotFound:
1161       return "The queue you specified does not exist.";
1162     case NERR_BadDevString:
1163       return "This list of devices is invalid.";
1164     case NERR_BadDev:
1165       return "The requested device is invalid.";
1166     case NERR_InUseBySpooler:
1167       return "This device is already in use by the spooler.";
1168     case NERR_CommDevInUse:
1169       return "This device is already in use as a communication device.";
1170     case NERR_InvalidComputer:
1171       return "This computer name is invalid.";
1172     case NERR_MaxLenExceeded:
1173       return "The string and prefix specified are too long.";
1174     case NERR_BadComponent:
1175       return "This path component is invalid.";
1176     case NERR_CantType:
1177       return "Could not determine the type of input.";
1178     case NERR_TooManyEntries:
1179       return "The buffer for types is not big enough.";
1180     case NERR_ProfileFileTooBig:
1181       return "Profile files cannot exceed 64K.";
1182     case NERR_ProfileOffset:
1183       return "The start offset is out of range.";
1184     case NERR_ProfileCleanup:
1185       return "The system cannot delete current connections to network resources.";
1186     case NERR_ProfileUnknownCmd:
1187       return "The system was unable to parse the command line in this file.";
1188     case NERR_ProfileLoadErr:
1189       return "An error occurred while loading the profile file.";
1190     case NERR_ProfileSaveErr:
1191       return "@W Errors occurred while saving the profile file. The profile was partially saved.";
1192     case NERR_LogOverflow:
1193       return "Log file %1 is full.";
1194     case NERR_LogFileChanged:
1195       return "This log file has changed between reads.";
1196     case NERR_LogFileCorrupt:
1197       return "Log file %1 is corrupt.";
1198     case NERR_SourceIsDir:
1199       return "The source path cannot be a directory.";
1200     case NERR_BadSource:
1201       return "The source path is illegal.";
1202     case NERR_BadDest:
1203       return "The destination path is illegal.";
1204     case NERR_DifferentServers:
1205       return "The source and destination paths are on different servers.";
1206     case NERR_RunSrvPaused:
1207       return "The Run server you requested is paused.";
1208     case NERR_ErrCommRunSrv:
1209       return "An error occurred when communicating with a Run server.";
1210     case NERR_ErrorExecingGhost:
1211       return "An error occurred when starting a background process.";
1212     case NERR_ShareNotFound:
1213       return "The shared resource you are connected to could not be found.";
1214     case NERR_InvalidLana:
1215       return "The LAN adapter number is invalid.";
1216     case NERR_OpenFiles:
1217       return "There are open files on the connection.";
1218     case NERR_ActiveConns:
1219       return "Active connections still exist.";
1220     case NERR_BadPasswordCore:
1221       return "This share name or password is invalid.";
1222     case NERR_DevInUse:
1223       return "The device is being accessed by an active process.";
1224     case NERR_LocalDrive:
1225       return "The drive letter is in use locally.";
1226     case NERR_AlertExists:
1227       return "The specified client is already registered for the specified event.";
1228     case NERR_TooManyAlerts:
1229       return "The alert table is full.";
1230     case NERR_NoSuchAlert:
1231       return "An invalid or nonexistent alert name was raised.";
1232     case NERR_BadRecipient:
1233       return "The alert recipient is invalid.";
1234     case NERR_AcctLimitExceeded:
1235       return "A user's session with this server has been deleted.";
1236     case NERR_InvalidLogSeek:
1237       return "The log file does not contain the requested record number.";
1238     case NERR_BadUasConfig:
1239       return "The user accounts database is not configured correctly.";
1240     case NERR_InvalidUASOp:
1241       return "This operation is not permitted when the Netlogon service is running.";
1242     case NERR_LastAdmin:
1243       return "This operation is not allowed on the last administrative account.";
1244     case NERR_DCNotFound:
1245       return "Could not find domain controller for this domain.";
1246     case NERR_LogonTrackingError:
1247       return "Could not set logon information for this user.";
1248     case NERR_NetlogonNotStarted:
1249       return "The Netlogon service has not been started.";
1250     case NERR_CanNotGrowUASFile:
1251       return "Unable to add to the user accounts database.";
1252     case NERR_TimeDiffAtDC:
1253       return "This server's clock is not synchronized with the primary domain controller's clock.";
1254     case NERR_PasswordMismatch:
1255       return "A password mismatch has been detected.";
1256     case NERR_NoSuchServer:
1257       return "The server identification does not specify a valid server.";
1258     case NERR_NoSuchSession:
1259       return "The session identification does not specify a valid session.";
1260     case NERR_NoSuchConnection:
1261       return "The connection identification does not specify a valid connection.";
1262     case NERR_TooManyServers:
1263       return "There is no space for another entry in the table of available servers.";
1264     case NERR_TooManySessions:
1265       return "The server has reached the maximum number of sessions it supports.";
1266     case NERR_TooManyConnections:
1267       return "The server has reached the maximum number of connections it supports.";
1268     case NERR_TooManyFiles:
1269       return "The server cannot open more files because it has reached its maximum number.";
1270     case NERR_NoAlternateServers:
1271       return "There are no alternate servers registered on this server.";
1272     case NERR_TryDownLevel:
1273       return "Try down-level (remote admin protocol) version of API instead.";
1274     case NERR_UPSDriverNotStarted:
1275       return "The UPS driver could not be accessed by the UPS service.";
1276     case NERR_UPSInvalidConfig:
1277       return "The UPS service is not configured correctly.";
1278     case NERR_UPSInvalidCommPort:
1279       return "The UPS service could not access the specified Comm Port.";
1280     case NERR_UPSSignalAsserted:
1281       return "The UPS indicated a line fail or low battery situation. Service not started.";
1282     case NERR_UPSShutdownFailed:
1283       return "The UPS service failed to perform a system shut down.";
1284     case NERR_BadDosRetCode:
1285       return "The program below returned an MS-DOS error code:";
1286     case NERR_ProgNeedsExtraMem:
1287       return "The program below needs more memory:";
1288     case NERR_BadDosFunction:
1289       return "The program below called an unsupported MS-DOS function:";
1290     case NERR_RemoteBootFailed:
1291       return "The workstation failed to boot.";
1292     case NERR_BadFileCheckSum:
1293       return "The file below is corrupt.";
1294     case NERR_NoRplBootSystem:
1295       return "No loader is specified in the boot-block definition file.";
1296     case NERR_RplLoadrNetBiosErr:
1297       return "NetBIOS returned an error:      The NCB and SMB are dumped above.";
1298     case NERR_RplLoadrDiskErr:
1299       return "A disk I/O error occurred.";
1300     case NERR_ImageParamErr:
1301       return "Image parameter substitution failed.";
1302     case NERR_TooManyImageParams:
1303       return "Too many image parameters cross disk sector boundaries.";
1304     case NERR_NonDosFloppyUsed:
1305       return "The image was not generated from an MS-DOS diskette formatted with /S.";
1306     case NERR_RplBootRestart:
1307       return "Remote boot will be restarted later.";
1308     case NERR_RplSrvrCallFailed:
1309       return "The call to the Remoteboot server failed.";
1310     case NERR_CantConnectRplSrvr:
1311       return "Cannot connect to the Remoteboot server.";
1312     case NERR_CantOpenImageFile:
1313       return "Cannot open image file on the Remoteboot server.";
1314     case NERR_CallingRplSrvr:
1315       return "Connecting to the Remoteboot server...";
1316     case NERR_StartingRplBoot:
1317       return "Connecting to the Remoteboot server...";
1318     case NERR_RplBootServiceTerm:
1319       return "Remote boot service was stopped; check the error log for the cause of the problem.";
1320     case NERR_RplBootStartFailed:
1321       return "Remote boot startup failed; check the error log for the cause of the problem.";
1322     case NERR_RPL_CONNECTED:
1323       return "A second connection to a Remoteboot resource is not allowed.";
1324     case NERR_BrowserConfiguredToNotRun:
1325       return "The browser service was configured with MaintainServerList=No.";
1326     case NERR_RplNoAdaptersStarted:
1327       return "Service failed to start since none of the network adapters started with this service.";
1328     case NERR_RplBadRegistry:
1329       return "Service failed to start due to bad startup information in the registry.";
1330     case NERR_RplBadDatabase:
1331       return "Service failed to start because its database is absent or corrupt.";
1332     case NERR_RplRplfilesShare:
1333       return "Service failed to start because RPLFILES share is absent.";
1334     case NERR_RplNotRplServer:
1335       return "Service failed to start because RPLUSER group is absent.";
1336     case NERR_RplCannotEnum:
1337       return "Cannot enumerate service records.";
1338     case NERR_RplWkstaInfoCorrupted:
1339       return "Workstation record information has been corrupted.";
1340     case NERR_RplWkstaNotFound:
1341       return "Workstation record was not found.";
1342     case NERR_RplWkstaNameUnavailable:
1343       return "Workstation name is in use by some other workstation.";
1344     case NERR_RplProfileInfoCorrupted:
1345       return "Profile record information has been corrupted.";
1346     case NERR_RplProfileNotFound:
1347       return "Profile record was not found.";
1348     case NERR_RplProfileNameUnavailable:
1349       return "Profile name is in use by some other profile.";
1350     case NERR_RplProfileNotEmpty:
1351       return "There are workstations using this profile.";
1352     case NERR_RplConfigInfoCorrupted:
1353       return "Configuration record information has been corrupted.";
1354     case NERR_RplConfigNotFound:
1355       return "Configuration record was not found.";
1356     case NERR_RplAdapterInfoCorrupted:
1357       return "Adapter ID record information has been corrupted.";
1358     case NERR_RplInternal:
1359       return "An internal service error has occurred.";
1360     case NERR_RplVendorInfoCorrupted:
1361       return "Vendor ID record information has been corrupted.";
1362     case NERR_RplBootInfoCorrupted:
1363       return "Boot block record information has been corrupted.";
1364     case NERR_RplWkstaNeedsUserAcct:
1365       return "The user account for this workstation record is missing.";
1366     case NERR_RplNeedsRPLUSERAcct:
1367       return "The RPLUSER local group could not be found.";
1368     case NERR_RplBootNotFound:
1369       return "Boot block record was not found.";
1370     case NERR_RplIncompatibleProfile:
1371       return "Chosen profile is incompatible with this workstation.";
1372     case NERR_RplAdapterNameUnavailable:
1373       return "Chosen network adapter ID is in use by some other workstation.";
1374     case NERR_RplConfigNotEmpty:
1375       return "There are profiles using this configuration.";
1376     case NERR_RplBootInUse:
1377       return "There are workstations, profiles, or configurations using this boot block.";
1378     case NERR_RplBackupDatabase:
1379       return "Service failed to backup Remoteboot database.";
1380     case NERR_RplAdapterNotFound:
1381       return "Adapter record was not found.";
1382     case NERR_RplVendorNotFound:
1383       return "Vendor record was not found.";
1384     case NERR_RplVendorNameUnavailable:
1385       return "Vendor name is in use by some other vendor record.";
1386     case NERR_RplBootNameUnavailable:
1387       return "(boot name, vendor ID) is in use by some other boot block record.";
1388     case NERR_RplConfigNameUnavailable:
1389       return "Configuration name is in use by some other configuration.";
1390     case NERR_DfsInternalCorruption:
1391       return "The internal database maintained by the Dfs service is corrupt.";
1392     case NERR_DfsVolumeDataCorrupt:
1393       return "One of the records in the internal Dfs database is corrupt.";
1394     case NERR_DfsNoSuchVolume:
1395       return "There is no DFS name whose entry path matches the input Entry Path.";
1396     case NERR_DfsVolumeAlreadyExists:
1397       return "A root or link with the given name already exists.";
1398     case NERR_DfsAlreadyShared:
1399       return "The server share specified is already shared in the Dfs.";
1400     case NERR_DfsNoSuchShare:
1401       return "The indicated server share does not support the indicated DFS namespace.";
1402     case NERR_DfsNotALeafVolume:
1403       return "The operation is not valid on this portion of the namespace.";
1404     case NERR_DfsLeafVolume:
1405       return "The operation is not valid on this portion of the namespace.";
1406     case NERR_DfsVolumeHasMultipleServers:
1407       return "The operation is ambiguous because the link has multiple servers.";
1408     case NERR_DfsCantCreateJunctionPoint:
1409       return "Unable to create a link.";
1410     case NERR_DfsServerNotDfsAware:
1411       return "The server is not Dfs Aware.";
1412     case NERR_DfsBadRenamePath:
1413       return "The specified rename target path is invalid.";
1414     case NERR_DfsVolumeIsOffline:
1415       return "The specified DFS link is offline.";
1416     case NERR_DfsNoSuchServer:
1417       return "The specified server is not a server for this link.";
1418     case NERR_DfsCyclicalName:
1419       return "A cycle in the Dfs name was detected.";
1420     case NERR_DfsNotSupportedInServerDfs:
1421       return "The operation is not supported on a server-based Dfs.";
1422     case NERR_DfsDuplicateService:
1423       return "This link is already supported by the specified server-share.";
1424     case NERR_DfsCantRemoveLastServerShare:
1425       return "Can't remove the last server-share supporting this root or link.";
1426     case NERR_DfsVolumeIsInterDfs:
1427       return "The operation is not supported for an Inter-DFS link.";
1428     case NERR_DfsInconsistent:
1429       return "The internal state of the Dfs Service has become inconsistent.";
1430     case NERR_DfsServerUpgraded:
1431       return "The Dfs Service has been installed on the specified server.";
1432     case NERR_DfsDataIsIdentical:
1433       return "The Dfs data being reconciled is identical.";
1434     case NERR_DfsCantRemoveDfsRoot:
1435       return "The DFS root cannot be deleted. Uninstall DFS if required.";
1436     case NERR_DfsChildOrParentInDfs:
1437       return "A child or parent directory of the share is already in a Dfs.";
1438     case NERR_DfsInternalError:
1439       return "Dfs internal error.";
1440       /* the following are not defined in mingw */
1441 #if 0
1442
1443     case NERR_SetupAlreadyJoined:
1444       return "This machine is already joined to a domain.";
1445     case NERR_SetupNotJoined:
1446       return "This machine is not currently joined to a domain.";
1447     case NERR_SetupDomainController:
1448       return "This machine is a domain controller and cannot be unjoined from a domain.";
1449     case NERR_DefaultJoinRequired:
1450       return "The destination domain controller does not support creating machine accounts in OUs.";
1451     case NERR_InvalidWorkgroupName:
1452       return "The specified workgroup name is invalid.";
1453     case NERR_NameUsesIncompatibleCodePage:
1454       return "The specified computer name is incompatible with the default language used on the domain controller.";
1455     case NERR_ComputerAccountNotFound:
1456       return "The specified computer account could not be found.";
1457     case NERR_PersonalSku:
1458       return "This version of Windows cannot be joined to a domain.";
1459     case NERR_PasswordMustChange:
1460       return "The password must change at the next logon.";
1461     case NERR_AccountLockedOut:
1462       return "The account is locked out.";
1463     case NERR_PasswordTooLong:
1464       return "The password is too long.";
1465     case NERR_PasswordNotComplexEnough:
1466       return "The password does not meet the complexity policy.";
1467     case NERR_PasswordFilterError:
1468       return "The password does not meet the requirements of the password filter DLLs.";
1469 #endif
1470
1471     }
1472   msg = strerror (error_number);
1473   if (msg == NULL)
1474     msg = "unknown";
1475
1476   return msg;
1477 #endif //DBUS_WINCE
1478 }
1479
1480 /**
1481  * Get a printable string describing the command used to execute
1482  * the process with pid.  This string should only be used for
1483  * informative purposes such as logging; it may not be trusted.
1484  *
1485  * The command is guaranteed to be printable ASCII and no longer
1486  * than max_len.
1487  *
1488  * @param pid Process id
1489  * @param str Append command to this string
1490  * @param max_len Maximum length of returned command
1491  * @param error return location for errors
1492  * @returns #FALSE on error
1493  */
1494 dbus_bool_t
1495 _dbus_command_for_pid (unsigned long  pid,
1496                        DBusString    *str,
1497                        int            max_len,
1498                        DBusError     *error)
1499 {
1500   // FIXME
1501   return FALSE;
1502 }