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