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