dbus-sysdeps-util-win.c

00001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
00002 /* dbus-sysdeps-util.c Would be in dbus-sysdeps.c, but not used in libdbus
00003  * 
00004  * Copyright (C) 2002, 2003, 2004, 2005  Red Hat, Inc.
00005  * Copyright (C) 2003 CodeFactory AB
00006  *
00007  * Licensed under the Academic Free License version 2.1
00008  * 
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  *
00023  */
00024 
00025 #undef open
00026 
00027 #define STRSAFE_NO_DEPRECATE
00028 
00029 #include "dbus-sysdeps.h"
00030 #include "dbus-internals.h"
00031 #include "dbus-protocol.h"
00032 #include "dbus-string.h"
00033 #include "dbus-sysdeps.h"
00034 #include "dbus-sysdeps-win.h"
00035 #include "dbus-memory.h"
00036 
00037 #include <io.h>
00038 #include <sys/stat.h>
00039 #include <aclapi.h>
00040 
00041 #include <stdio.h>
00042 #include <stdlib.h>
00043 #include <fcntl.h>
00044 #include <errno.h>
00045 
00046 #if defined __MINGW32__ || (defined _MSC_VER && _MSC_VER <= 1310)
00047 /* save string functions version
00048    using DBusString needs to much time because of uncommon api 
00049 */ 
00050 #define errno_t int
00051 
00052 errno_t strcat_s(char *dest, size_t size, char *src) 
00053 {
00054   _dbus_assert(strlen(dest) + strlen(src) +1 <= size);
00055   strcat(dest,src);
00056   return 0;
00057 }
00058 
00059 errno_t strcpy_s(char *dest, size_t size, char *src)
00060 {
00061   _dbus_assert(strlen(src) +1 <= size);
00062   strcpy(dest,src);  
00063   return 0;
00064 }
00065 #endif
00066 
00075 dbus_bool_t
00076 _dbus_become_daemon (const DBusString *pidfile,
00077                      DBusPipe         *print_pid_pipe,
00078                      DBusError        *error)
00079 {
00080   return TRUE;
00081 }
00082 
00091 dbus_bool_t
00092 _dbus_write_pid_file (const DBusString *filename,
00093                       unsigned long     pid,
00094                       DBusError        *error)
00095 {
00096   const char *cfilename;
00097   DBusFile file;
00098   FILE *f;
00099 
00100   cfilename = _dbus_string_get_const_data (filename);
00101 
00102   if (!_dbus_file_open(&file, cfilename, O_WRONLY|O_CREAT|O_EXCL|O_BINARY, 0644))
00103     {
00104       dbus_set_error (error, _dbus_error_from_errno (errno),
00105                       "Failed to open \"%s\": %s", cfilename,
00106                       _dbus_strerror (errno));
00107       return FALSE;
00108     }
00109 
00110   if ((f = fdopen (file.FDATA, "w")) == NULL)
00111     {
00112       dbus_set_error (error, _dbus_error_from_errno (errno),
00113                       "Failed to fdopen fd %d: %s", file.FDATA, _dbus_strerror (errno));
00114       _dbus_file_close (&file, NULL);
00115       return FALSE;
00116     }
00117 
00118   if (fprintf (f, "%lu\n", pid) < 0)
00119     {
00120       dbus_set_error (error, _dbus_error_from_errno (errno),
00121                       "Failed to write to \"%s\": %s", cfilename,
00122                       _dbus_strerror (errno));
00123 
00124       fclose (f);
00125       return FALSE;
00126     }
00127 
00128   if (fclose (f) == EOF)
00129     {
00130       dbus_set_error (error, _dbus_error_from_errno (errno),
00131                       "Failed to close \"%s\": %s", cfilename,
00132                       _dbus_strerror (errno));
00133       return FALSE;
00134     }
00135 
00136   return TRUE;
00137 }
00138 
00145 dbus_bool_t
00146 _dbus_verify_daemon_user (const char *user)
00147 {
00148   return TRUE;
00149 }
00150 
00158 dbus_bool_t
00159 _dbus_change_to_daemon_user  (const char    *user,
00160                               DBusError     *error)
00161 {
00162   return TRUE;
00163 }
00164 
00173 dbus_bool_t
00174 _dbus_change_identity  (dbus_uid_t     uid,
00175                         dbus_gid_t     gid,
00176                         DBusError     *error)
00177 {
00178   return TRUE;
00179 }
00180 
00187 dbus_bool_t
00188 _dbus_user_at_console(const char *username,
00189                       DBusError  *error)
00190 {
00191 #ifdef DBUS_WINCE
00192         return TRUE;
00193 #else
00194   dbus_bool_t retval = FALSE;
00195   wchar_t *wusername;
00196   DWORD sid_length;
00197   PSID user_sid, console_user_sid;
00198   HWINSTA winsta;
00199 
00200   wusername = _dbus_win_utf8_to_utf16 (username, error);
00201   if (!wusername)
00202     return FALSE;
00203 
00204   // TODO remove
00205   if (!_dbus_win_account_to_sid (wusername, &user_sid, error))
00206     goto out0;
00207 
00208   /* Now we have the SID for username. Get the SID of the
00209    * user at the "console" (window station WinSta0)
00210    */
00211   if (!(winsta = OpenWindowStation ("WinSta0", FALSE, READ_CONTROL)))
00212     {
00213       _dbus_win_set_error_from_win_error (error, GetLastError ());
00214       goto out2;
00215     }
00216 
00217   sid_length = 0;
00218   GetUserObjectInformation (winsta, UOI_USER_SID,
00219                             NULL, 0, &sid_length);
00220   if (sid_length == 0)
00221     {
00222       /* Nobody is logged on */
00223       goto out2;
00224     }
00225 
00226   if (sid_length < 0 || sid_length > 1000)
00227     {
00228       dbus_set_error_const (error, DBUS_ERROR_FAILED, "Invalid SID length");
00229       goto out3;
00230     }
00231 
00232   console_user_sid = dbus_malloc (sid_length);
00233   if (!console_user_sid)
00234     {
00235       _DBUS_SET_OOM (error);
00236       goto out3;
00237     }
00238 
00239   if (!GetUserObjectInformation (winsta, UOI_USER_SID,
00240                                  console_user_sid, sid_length, &sid_length))
00241     {
00242       _dbus_win_set_error_from_win_error (error, GetLastError ());
00243       goto out4;
00244     }
00245 
00246   if (!IsValidSid (console_user_sid))
00247     {
00248       dbus_set_error_const (error, DBUS_ERROR_FAILED, "Invalid SID");
00249       goto out4;
00250     }
00251 
00252   retval = EqualSid (user_sid, console_user_sid);
00253 
00254 out4:
00255   dbus_free (console_user_sid);
00256 out3:
00257   CloseWindowStation (winsta);
00258 out2:
00259   dbus_free (user_sid);
00260 out0:
00261   dbus_free (wusername);
00262 
00263   return retval;
00264 #endif //DBUS_WINCE
00265 }
00266 
00274 dbus_bool_t
00275 _dbus_delete_directory (const DBusString *filename,
00276                         DBusError        *error)
00277 {
00278   const char *filename_c;
00279 
00280   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
00281 
00282   filename_c = _dbus_string_get_const_data (filename);
00283 
00284   if (rmdir (filename_c) != 0)
00285     {
00286       dbus_set_error (error, DBUS_ERROR_FAILED,
00287                       "Failed to remove directory %s: %s\n",
00288                       filename_c, _dbus_strerror (errno));
00289       return FALSE;
00290     }
00291 
00292   return TRUE;
00293 }
00294 
00300 void
00301 _dbus_set_signal_handler (int               sig,
00302                           DBusSignalHandler handler)
00303 {
00304   _dbus_verbose ("_dbus_set_signal_handler() has to be implemented\n");
00305 }
00306 
00312 dbus_bool_t 
00313 _dbus_file_exists (const char *file)
00314 {
00315   HANDLE h = CreateFile(
00316           file, /* LPCTSTR lpFileName*/
00317           0, /* DWORD dwDesiredAccess */
00318           0, /* DWORD dwShareMode*/
00319           NULL, /* LPSECURITY_ATTRIBUTES lpSecurityAttributes */
00320           OPEN_EXISTING, /* DWORD dwCreationDisposition */
00321           FILE_ATTRIBUTE_NORMAL, /* DWORD dwFlagsAndAttributes */
00322           NULL /* HANDLE hTemplateFile */
00323         );
00324 
00325     /* file not found, use local copy of session.conf  */
00326     if (h != INVALID_HANDLE_VALUE && GetLastError() != ERROR_PATH_NOT_FOUND)
00327       {
00328         CloseHandle(h);
00329         return TRUE;
00330       }
00331     else
00332         return FALSE;  
00333 }
00334 
00343 dbus_bool_t
00344 _dbus_stat(const DBusString *filename,
00345            DBusStat         *statbuf,
00346            DBusError        *error)
00347 {
00348 #ifdef DBUS_WINCE
00349         return TRUE;
00350         //TODO
00351 #else
00352   const char *filename_c;
00353 #if !defined(DBUS_WIN) && !defined(DBUS_WINCE)
00354 
00355   struct stat sb;
00356 #else
00357 
00358   WIN32_FILE_ATTRIBUTE_DATA wfad;
00359   char *lastdot;
00360   DWORD rc;
00361   PSID owner_sid, group_sid;
00362   PSECURITY_DESCRIPTOR sd;
00363 #endif
00364 
00365   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
00366 
00367   filename_c = _dbus_string_get_const_data (filename);
00368 
00369   if (!GetFileAttributesEx (filename_c, GetFileExInfoStandard, &wfad))
00370     {
00371       _dbus_win_set_error_from_win_error (error, GetLastError ());
00372       return FALSE;
00373     }
00374 
00375   if (wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
00376     statbuf->mode = _S_IFDIR;
00377   else
00378     statbuf->mode = _S_IFREG;
00379 
00380   statbuf->mode |= _S_IREAD;
00381   if (wfad.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
00382     statbuf->mode |= _S_IWRITE;
00383 
00384   lastdot = strrchr (filename_c, '.');
00385   if (lastdot && stricmp (lastdot, ".exe") == 0)
00386     statbuf->mode |= _S_IEXEC;
00387 
00388   statbuf->mode |= (statbuf->mode & 0700) >> 3;
00389   statbuf->mode |= (statbuf->mode & 0700) >> 6;
00390 
00391   statbuf->nlink = 1;
00392 
00393   sd = NULL;
00394   rc = GetNamedSecurityInfo ((char *) filename_c, SE_FILE_OBJECT,
00395                              OWNER_SECURITY_INFORMATION |
00396                              GROUP_SECURITY_INFORMATION,
00397                              &owner_sid, &group_sid,
00398                              NULL, NULL,
00399                              &sd);
00400   if (rc != ERROR_SUCCESS)
00401     {
00402       _dbus_win_set_error_from_win_error (error, rc);
00403       if (sd != NULL)
00404         LocalFree (sd);
00405       return FALSE;
00406     }
00407 
00408 #ifdef ENABLE_UID_TO_SID
00409   /* FIXME */
00410   statbuf->uid = _dbus_win_sid_to_uid_t (owner_sid);
00411   statbuf->gid = _dbus_win_sid_to_uid_t (group_sid);
00412 #endif
00413 
00414   LocalFree (sd);
00415 
00416   statbuf->size = ((dbus_int64_t) wfad.nFileSizeHigh << 32) + wfad.nFileSizeLow;
00417 
00418   statbuf->atime =
00419     (((dbus_int64_t) wfad.ftLastAccessTime.dwHighDateTime << 32) +
00420      wfad.ftLastAccessTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
00421 
00422   statbuf->mtime =
00423     (((dbus_int64_t) wfad.ftLastWriteTime.dwHighDateTime << 32) +
00424      wfad.ftLastWriteTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
00425 
00426   statbuf->ctime =
00427     (((dbus_int64_t) wfad.ftCreationTime.dwHighDateTime << 32) +
00428      wfad.ftCreationTime.dwLowDateTime) / 10000000 - DBUS_INT64_CONSTANT (116444736000000000);
00429 
00430   return TRUE;
00431 #endif //DBUS_WINCE
00432 }
00433 
00434 
00435 #ifdef HAVE_DIRENT_H
00436 
00437 // mingw ships with dirent.h
00438 #include <dirent.h>
00439 #define _dbus_opendir opendir
00440 #define _dbus_readdir readdir
00441 #define _dbus_closedir closedir
00442 
00443 #else
00444 
00445 #ifdef HAVE_IO_H
00446 #include <io.h> // win32 file functions
00447 #endif
00448 
00449 #include <sys/types.h>
00450 #include <stdlib.h>
00451 
00452 /* This file is part of the KDE project
00453 Copyright (C) 2000 Werner Almesberger
00454 
00455 libc/sys/linux/sys/dirent.h - Directory entry as returned by readdir
00456 
00457 This program is free software; you can redistribute it and/or
00458 modify it under the terms of the GNU Library General Public
00459 License as published by the Free Software Foundation; either
00460 version 2 of the License, or (at your option) any later version.
00461 
00462 This program is distributed in the hope that it will be useful,
00463 but WITHOUT ANY WARRANTY; without even the implied warranty of
00464 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00465 Library General Public License for more details.
00466 
00467 You should have received a copy of the GNU Library General Public License
00468 along with this program; see the file COPYING.  If not, write to
00469 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00470 Boston, MA 02110-1301, USA.
00471 */
00472 #define HAVE_NO_D_NAMLEN        /* no struct dirent->d_namlen */
00473 #define HAVE_DD_LOCK            /* have locking mechanism */
00474 
00475 #define MAXNAMLEN 255           /* sizeof(struct dirent.d_name)-1 */
00476 
00477 #define __dirfd(dir) (dir)->dd_fd
00478 
00479 /* struct dirent - same as Unix */
00480 struct dirent
00481   {
00482     long d_ino;                    /* inode (always 1 in WIN32) */
00483     off_t d_off;                /* offset to this dirent */
00484     unsigned short d_reclen;    /* length of d_name */
00485     char d_name[_MAX_FNAME+1];    /* filename (null terminated) */
00486   };
00487 
00488 /* typedef DIR - not the same as Unix */
00489 typedef struct
00490   {
00491     long handle;                /* _findfirst/_findnext handle */
00492     short offset;                /* offset into directory */
00493     short finished;             /* 1 if there are not more files */
00494     struct _finddata_t fileinfo;  /* from _findfirst/_findnext */
00495     char *dir;                  /* the dir we are reading */
00496     struct dirent dent;         /* the dirent to return */
00497   }
00498 DIR;
00499 
00500 /**********************************************************************
00501 * Implement dirent-style opendir/readdir/closedir on Window 95/NT
00502 *
00503 * Functions defined are opendir(), readdir() and closedir() with the
00504 * same prototypes as the normal dirent.h implementation.
00505 *
00506 * Does not implement telldir(), seekdir(), rewinddir() or scandir().
00507 * The dirent struct is compatible with Unix, except that d_ino is
00508 * always 1 and d_off is made up as we go along.
00509 *
00510 * The DIR typedef is not compatible with Unix.
00511 **********************************************************************/
00512 
00513 DIR * _dbus_opendir(const char *dir)
00514 {
00515   DIR *dp;
00516   char *filespec;
00517   long handle;
00518   int index;
00519 
00520   filespec = malloc(strlen(dir) + 2 + 1);
00521   strcpy(filespec, dir);
00522   index = strlen(filespec) - 1;
00523   if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\'))
00524     filespec[index] = '\0';
00525   strcat(filespec, "\\*");
00526 
00527   dp = (DIR *)malloc(sizeof(DIR));
00528   dp->offset = 0;
00529   dp->finished = 0;
00530   dp->dir = strdup(dir);
00531 
00532   if ((handle = _findfirst(filespec, &(dp->fileinfo))) < 0)
00533     {
00534       if (errno == ENOENT)
00535         dp->finished = 1;
00536       else
00537         return NULL;
00538     }
00539 
00540   dp->handle = handle;
00541   free(filespec);
00542 
00543   return dp;
00544 }
00545 
00546 struct dirent * _dbus_readdir(DIR *dp)
00547   {
00548     if (!dp || dp->finished)
00549       return NULL;
00550 
00551     if (dp->offset != 0)
00552       {
00553         if (_findnext(dp->handle, &(dp->fileinfo)) < 0)
00554           {
00555             dp->finished = 1;
00556             errno = 0;
00557             return NULL;
00558           }
00559       }
00560     dp->offset++;
00561 
00562     strncpy(dp->dent.d_name, dp->fileinfo.name, _MAX_FNAME);
00563     dp->dent.d_ino = 1;
00564     dp->dent.d_reclen = strlen(dp->dent.d_name);
00565     dp->dent.d_off = dp->offset;
00566 
00567     return &(dp->dent);
00568   }
00569 
00570 
00571 int _dbus_closedir(DIR *dp)
00572 {
00573   if (!dp)
00574     return 0;
00575   _findclose(dp->handle);
00576   if (dp->dir)
00577     free(dp->dir);
00578   if (dp)
00579     free(dp);
00580 
00581   return 0;
00582 }
00583 
00584 #endif //#ifdef HAVE_DIRENT_H
00585 
00589 struct DBusDirIter
00590   {
00591     DIR *d; 
00593   };
00594 
00602 DBusDirIter*
00603 _dbus_directory_open (const DBusString *filename,
00604                       DBusError        *error)
00605 {
00606   DIR *d;
00607   DBusDirIter *iter;
00608   const char *filename_c;
00609 
00610   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
00611 
00612   filename_c = _dbus_string_get_const_data (filename);
00613 
00614   d = _dbus_opendir (filename_c);
00615   if (d == NULL)
00616     {
00617       dbus_set_error (error, _dbus_error_from_errno (errno),
00618                       "Failed to read directory \"%s\": %s",
00619                       filename_c,
00620                       _dbus_strerror (errno));
00621       return NULL;
00622     }
00623   iter = dbus_new0 (DBusDirIter, 1);
00624   if (iter == NULL)
00625     {
00626       _dbus_closedir (d);
00627       dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
00628                       "Could not allocate memory for directory iterator");
00629       return NULL;
00630     }
00631 
00632   iter->d = d;
00633 
00634   return iter;
00635 }
00636 
00650 dbus_bool_t
00651 _dbus_directory_get_next_file (DBusDirIter      *iter,
00652                                DBusString       *filename,
00653                                DBusError        *error)
00654 {
00655   struct dirent *ent;
00656 
00657   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
00658 
00659 again:
00660   errno = 0;
00661   ent = _dbus_readdir (iter->d);
00662   if (ent == NULL)
00663     {
00664       if (errno != 0)
00665         dbus_set_error (error,
00666                         _dbus_error_from_errno (errno),
00667                         "%s", _dbus_strerror (errno));
00668       return FALSE;
00669     }
00670   else if (ent->d_name[0] == '.' &&
00671            (ent->d_name[1] == '\0' ||
00672             (ent->d_name[1] == '.' && ent->d_name[2] == '\0')))
00673     goto again;
00674   else
00675     {
00676       _dbus_string_set_length (filename, 0);
00677       if (!_dbus_string_append (filename, ent->d_name))
00678         {
00679           dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
00680                           "No memory to read directory entry");
00681           return FALSE;
00682         }
00683       else
00684         return TRUE;
00685     }
00686 }
00687 
00691 void
00692 _dbus_directory_close (DBusDirIter *iter)
00693 {
00694   _dbus_closedir (iter->d);
00695   dbus_free (iter);
00696 }
00697 
00704 dbus_bool_t
00705 _dbus_path_is_absolute (const DBusString *filename)
00706 {
00707   if (_dbus_string_get_length (filename) > 0)
00708     return _dbus_string_get_byte (filename, 1) == ':'
00709            || _dbus_string_get_byte (filename, 0) == '\\'
00710            || _dbus_string_get_byte (filename, 0) == '/';
00711   else
00712     return FALSE;
00713 }
00714  /* End of DBusInternalsUtils functions */
00716 
00728 dbus_bool_t
00729 _dbus_string_get_dirname(const DBusString *filename,
00730                          DBusString       *dirname)
00731 {
00732   int sep;
00733 
00734   _dbus_assert (filename != dirname);
00735   _dbus_assert (filename != NULL);
00736   _dbus_assert (dirname != NULL);
00737 
00738   /* Ignore any separators on the end */
00739   sep = _dbus_string_get_length (filename);
00740   if (sep == 0)
00741     return _dbus_string_append (dirname, "."); /* empty string passed in */
00742 
00743   while (sep > 0 &&
00744          (_dbus_string_get_byte (filename, sep - 1) == '/' ||
00745           _dbus_string_get_byte (filename, sep - 1) == '\\'))
00746     --sep;
00747 
00748   _dbus_assert (sep >= 0);
00749 
00750   if (sep == 0 ||
00751       (sep == 2 &&
00752        _dbus_string_get_byte (filename, 1) == ':' &&
00753        isalpha (_dbus_string_get_byte (filename, 0))))
00754     return _dbus_string_copy_len (filename, 0, sep + 1,
00755                                   dirname, _dbus_string_get_length (dirname));
00756 
00757   {
00758     int sep1, sep2;
00759     _dbus_string_find_byte_backward (filename, sep, '/', &sep1);
00760     _dbus_string_find_byte_backward (filename, sep, '\\', &sep2);
00761 
00762     sep = MAX (sep1, sep2);
00763   }
00764   if (sep < 0)
00765     return _dbus_string_append (dirname, ".");
00766 
00767   while (sep > 0 &&
00768          (_dbus_string_get_byte (filename, sep - 1) == '/' ||
00769           _dbus_string_get_byte (filename, sep - 1) == '\\'))
00770     --sep;
00771 
00772   _dbus_assert (sep >= 0);
00773 
00774   if ((sep == 0 ||
00775        (sep == 2 &&
00776         _dbus_string_get_byte (filename, 1) == ':' &&
00777         isalpha (_dbus_string_get_byte (filename, 0))))
00778       &&
00779       (_dbus_string_get_byte (filename, sep) == '/' ||
00780        _dbus_string_get_byte (filename, sep) == '\\'))
00781     return _dbus_string_copy_len (filename, 0, sep + 1,
00782                                   dirname, _dbus_string_get_length (dirname));
00783   else
00784     return _dbus_string_copy_len (filename, 0, sep - 0,
00785                                   dirname, _dbus_string_get_length (dirname));
00786 }
00787 
00788 
00796 dbus_bool_t
00797 _dbus_unix_user_is_process_owner (dbus_uid_t uid)
00798 {
00799   return FALSE;
00800 }
00801 
00802 /*=====================================================================
00803   unix emulation functions - should be removed sometime in the future
00804  =====================================================================*/
00805 
00815 dbus_bool_t
00816 _dbus_unix_user_is_at_console (dbus_uid_t         uid,
00817                                DBusError         *error)
00818 {
00819   return FALSE;
00820 }
00821 
00822 
00831 dbus_bool_t
00832 _dbus_parse_unix_group_from_config (const DBusString  *groupname,
00833                                     dbus_gid_t        *gid_p)
00834 {
00835   return FALSE;
00836 }
00837 
00846 dbus_bool_t
00847 _dbus_parse_unix_user_from_config (const DBusString  *username,
00848                                    dbus_uid_t        *uid_p)
00849 {
00850   return FALSE;
00851 }
00852 
00853 
00864 dbus_bool_t
00865 _dbus_unix_groups_from_uid (dbus_uid_t            uid,
00866                             dbus_gid_t          **group_ids,
00867                             int                  *n_group_ids)
00868 {
00869   return FALSE;
00870 }
00871 
00872 
00873  /* DBusString stuff */
00875 
00876 /************************************************************************
00877  
00878  error handling
00879  
00880  ************************************************************************/
00881 
00882 
00890 void
00891 _dbus_win_set_error_from_win_error (DBusError *error,
00892                                     int        code)
00893 {
00894   char *msg;
00895 
00896   /* As we want the English message, use the A API */
00897   FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER |
00898                   FORMAT_MESSAGE_IGNORE_INSERTS |
00899                   FORMAT_MESSAGE_FROM_SYSTEM,
00900                   NULL, code, MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US),
00901                   (LPTSTR) &msg, 0, NULL);
00902   if (msg)
00903     {
00904       char *msg_copy;
00905 
00906       msg_copy = dbus_malloc (strlen (msg));
00907       strcpy (msg_copy, msg);
00908       LocalFree (msg);
00909 
00910       dbus_set_error (error, "win32.error", "%s", msg_copy);
00911     }
00912   else
00913     dbus_set_error (error, "win32.error", "Unknown error code %d or FormatMessage failed", code);
00914 }
00915 
00916 void
00917 _dbus_win_warn_win_error (const char *message,
00918                           int         code)
00919 {
00920   DBusError error;
00921 
00922   dbus_error_init (&error);
00923   _dbus_win_set_error_from_win_error (&error, code);
00924   _dbus_warn ("%s: %s\n", message, error.message);
00925   dbus_error_free (&error);
00926 }
00927 
00935 const char*
00936 _dbus_strerror (int error_number)
00937 {
00938 #ifdef DBUS_WINCE
00939   // TODO
00940   return "unknown";
00941 #else
00942   const char *msg;
00943 
00944   switch (error_number)
00945     {
00946     case WSAEINTR:
00947       return "Interrupted function call";
00948     case WSAEACCES:
00949       return "Permission denied";
00950     case WSAEFAULT:
00951       return "Bad address";
00952     case WSAEINVAL:
00953       return "Invalid argument";
00954     case WSAEMFILE:
00955       return "Too many open files";
00956     case WSAEWOULDBLOCK:
00957       return "Resource temporarily unavailable";
00958     case WSAEINPROGRESS:
00959       return "Operation now in progress";
00960     case WSAEALREADY:
00961       return "Operation already in progress";
00962     case WSAENOTSOCK:
00963       return "Socket operation on nonsocket";
00964     case WSAEDESTADDRREQ:
00965       return "Destination address required";
00966     case WSAEMSGSIZE:
00967       return "Message too long";
00968     case WSAEPROTOTYPE:
00969       return "Protocol wrong type for socket";
00970     case WSAENOPROTOOPT:
00971       return "Bad protocol option";
00972     case WSAEPROTONOSUPPORT:
00973       return "Protocol not supported";
00974     case WSAESOCKTNOSUPPORT:
00975       return "Socket type not supported";
00976     case WSAEOPNOTSUPP:
00977       return "Operation not supported";
00978     case WSAEPFNOSUPPORT:
00979       return "Protocol family not supported";
00980     case WSAEAFNOSUPPORT:
00981       return "Address family not supported by protocol family";
00982     case WSAEADDRINUSE:
00983       return "Address already in use";
00984     case WSAEADDRNOTAVAIL:
00985       return "Cannot assign requested address";
00986     case WSAENETDOWN:
00987       return "Network is down";
00988     case WSAENETUNREACH:
00989       return "Network is unreachable";
00990     case WSAENETRESET:
00991       return "Network dropped connection on reset";
00992     case WSAECONNABORTED:
00993       return "Software caused connection abort";
00994     case WSAECONNRESET:
00995       return "Connection reset by peer";
00996     case WSAENOBUFS:
00997       return "No buffer space available";
00998     case WSAEISCONN:
00999       return "Socket is already connected";
01000     case WSAENOTCONN:
01001       return "Socket is not connected";
01002     case WSAESHUTDOWN:
01003       return "Cannot send after socket shutdown";
01004     case WSAETIMEDOUT:
01005       return "Connection timed out";
01006     case WSAECONNREFUSED:
01007       return "Connection refused";
01008     case WSAEHOSTDOWN:
01009       return "Host is down";
01010     case WSAEHOSTUNREACH:
01011       return "No route to host";
01012     case WSAEPROCLIM:
01013       return "Too many processes";
01014     case WSAEDISCON:
01015       return "Graceful shutdown in progress";
01016     case WSATYPE_NOT_FOUND:
01017       return "Class type not found";
01018     case WSAHOST_NOT_FOUND:
01019       return "Host not found";
01020     case WSATRY_AGAIN:
01021       return "Nonauthoritative host not found";
01022     case WSANO_RECOVERY:
01023       return "This is a nonrecoverable error";
01024     case WSANO_DATA:
01025       return "Valid name, no data record of requested type";
01026     case WSA_INVALID_HANDLE:
01027       return "Specified event object handle is invalid";
01028     case WSA_INVALID_PARAMETER:
01029       return "One or more parameters are invalid";
01030     case WSA_IO_INCOMPLETE:
01031       return "Overlapped I/O event object not in signaled state";
01032     case WSA_IO_PENDING:
01033       return "Overlapped operations will complete later";
01034     case WSA_NOT_ENOUGH_MEMORY:
01035       return "Insufficient memory available";
01036     case WSA_OPERATION_ABORTED:
01037       return "Overlapped operation aborted";
01038 #ifdef WSAINVALIDPROCTABLE
01039 
01040     case WSAINVALIDPROCTABLE:
01041       return "Invalid procedure table from service provider";
01042 #endif
01043 #ifdef WSAINVALIDPROVIDER
01044 
01045     case WSAINVALIDPROVIDER:
01046       return "Invalid service provider version number";
01047 #endif
01048 #ifdef WSAPROVIDERFAILEDINIT
01049 
01050     case WSAPROVIDERFAILEDINIT:
01051       return "Unable to initialize a service provider";
01052 #endif
01053 
01054     case WSASYSCALLFAILURE:
01055       return "System call failure";
01056     }
01057   msg = strerror (error_number);
01058   if (msg == NULL)
01059     msg = "unknown";
01060 
01061   return msg;
01062 #endif //DBUS_WINCE
01063 }
01064 
01065 
01066 
01067 /* lan manager error codes */
01068 const char*
01069 _dbus_lm_strerror(int error_number)
01070 {
01071 #ifdef DBUS_WINCE
01072   // TODO
01073   return "unknown";
01074 #else
01075   const char *msg;
01076   switch (error_number)
01077     {
01078     case NERR_NetNotStarted:
01079       return "The workstation driver is not installed.";
01080     case NERR_UnknownServer:
01081       return "The server could not be located.";
01082     case NERR_ShareMem:
01083       return "An internal error occurred. The network cannot access a shared memory segment.";
01084     case NERR_NoNetworkResource:
01085       return "A network resource shortage occurred.";
01086     case NERR_RemoteOnly:
01087       return "This operation is not supported on workstations.";
01088     case NERR_DevNotRedirected:
01089       return "The device is not connected.";
01090     case NERR_ServerNotStarted:
01091       return "The Server service is not started.";
01092     case NERR_ItemNotFound:
01093       return "The queue is empty.";
01094     case NERR_UnknownDevDir:
01095       return "The device or directory does not exist.";
01096     case NERR_RedirectedPath:
01097       return "The operation is invalid on a redirected resource.";
01098     case NERR_DuplicateShare:
01099       return "The name has already been shared.";
01100     case NERR_NoRoom:
01101       return "The server is currently out of the requested resource.";
01102     case NERR_TooManyItems:
01103       return "Requested addition of items exceeds the maximum allowed.";
01104     case NERR_InvalidMaxUsers:
01105       return "The Peer service supports only two simultaneous users.";
01106     case NERR_BufTooSmall:
01107       return "The API return buffer is too small.";
01108     case NERR_RemoteErr:
01109       return "A remote API error occurred.";
01110     case NERR_LanmanIniError:
01111       return "An error occurred when opening or reading the configuration file.";
01112     case NERR_NetworkError:
01113       return "A general network error occurred.";
01114     case NERR_WkstaInconsistentState:
01115       return "The Workstation service is in an inconsistent state. Restart the computer before restarting the Workstation service.";
01116     case NERR_WkstaNotStarted:
01117       return "The Workstation service has not been started.";
01118     case NERR_BrowserNotStarted:
01119       return "The requested information is not available.";
01120     case NERR_InternalError:
01121       return "An internal error occurred.";
01122     case NERR_BadTransactConfig:
01123       return "The server is not configured for transactions.";
01124     case NERR_InvalidAPI:
01125       return "The requested API is not supported on the remote server.";
01126     case NERR_BadEventName:
01127       return "The event name is invalid.";
01128     case NERR_DupNameReboot:
01129       return "The computer name already exists on the network. Change it and restart the computer.";
01130     case NERR_CfgCompNotFound:
01131       return "The specified component could not be found in the configuration information.";
01132     case NERR_CfgParamNotFound:
01133       return "The specified parameter could not be found in the configuration information.";
01134     case NERR_LineTooLong:
01135       return "A line in the configuration file is too long.";
01136     case NERR_QNotFound:
01137       return "The printer does not exist.";
01138     case NERR_JobNotFound:
01139       return "The print job does not exist.";
01140     case NERR_DestNotFound:
01141       return "The printer destination cannot be found.";
01142     case NERR_DestExists:
01143       return "The printer destination already exists.";
01144     case NERR_QExists:
01145       return "The printer queue already exists.";
01146     case NERR_QNoRoom:
01147       return "No more printers can be added.";
01148     case NERR_JobNoRoom:
01149       return "No more print jobs can be added.";
01150     case NERR_DestNoRoom:
01151       return "No more printer destinations can be added.";
01152     case NERR_DestIdle:
01153       return "This printer destination is idle and cannot accept control operations.";
01154     case NERR_DestInvalidOp:
01155       return "This printer destination request contains an invalid control function.";
01156     case NERR_ProcNoRespond:
01157       return "The print processor is not responding.";
01158     case NERR_SpoolerNotLoaded:
01159       return "The spooler is not running.";
01160     case NERR_DestInvalidState:
01161       return "This operation cannot be performed on the print destination in its current state.";
01162     case NERR_QInvalidState:
01163       return "This operation cannot be performed on the printer queue in its current state.";
01164     case NERR_JobInvalidState:
01165       return "This operation cannot be performed on the print job in its current state.";
01166     case NERR_SpoolNoMemory:
01167       return "A spooler memory allocation failure occurred.";
01168     case NERR_DriverNotFound:
01169       return "The device driver does not exist.";
01170     case NERR_DataTypeInvalid:
01171       return "The data type is not supported by the print processor.";
01172     case NERR_ProcNotFound:
01173       return "The print processor is not installed.";
01174     case NERR_ServiceTableLocked:
01175       return "The service database is locked.";
01176     case NERR_ServiceTableFull:
01177       return "The service table is full.";
01178     case NERR_ServiceInstalled:
01179       return "The requested service has already been started.";
01180     case NERR_ServiceEntryLocked:
01181       return "The service does not respond to control actions.";
01182     case NERR_ServiceNotInstalled:
01183       return "The service has not been started.";
01184     case NERR_BadServiceName:
01185       return "The service name is invalid.";
01186     case NERR_ServiceCtlTimeout:
01187       return "The service is not responding to the control function.";
01188     case NERR_ServiceCtlBusy:
01189       return "The service control is busy.";
01190     case NERR_BadServiceProgName:
01191       return "The configuration file contains an invalid service program name.";
01192     case NERR_ServiceNotCtrl:
01193       return "The service could not be controlled in its present state.";
01194     case NERR_ServiceKillProc:
01195       return "The service ended abnormally.";
01196     case NERR_ServiceCtlNotValid:
01197       return "The requested pause or stop is not valid for this service.";
01198     case NERR_NotInDispatchTbl:
01199       return "The service control dispatcher could not find the service name in the dispatch table.";
01200     case NERR_BadControlRecv:
01201       return "The service control dispatcher pipe read failed.";
01202     case NERR_ServiceNotStarting:
01203       return "A thread for the new service could not be created.";
01204     case NERR_AlreadyLoggedOn:
01205       return "This workstation is already logged on to the local-area network.";
01206     case NERR_NotLoggedOn:
01207       return "The workstation is not logged on to the local-area network.";
01208     case NERR_BadUsername:
01209       return "The user name or group name parameter is invalid.";
01210     case NERR_BadPassword:
01211       return "The password parameter is invalid.";
01212     case NERR_UnableToAddName_W:
01213       return "@W The logon processor did not add the message alias.";
01214     case NERR_UnableToAddName_F:
01215       return "The logon processor did not add the message alias.";
01216     case NERR_UnableToDelName_W:
01217       return "@W The logoff processor did not delete the message alias.";
01218     case NERR_UnableToDelName_F:
01219       return "The logoff processor did not delete the message alias.";
01220     case NERR_LogonsPaused:
01221       return "Network logons are paused.";
01222     case NERR_LogonServerConflict:
01223       return "A centralized logon-server conflict occurred.";
01224     case NERR_LogonNoUserPath:
01225       return "The server is configured without a valid user path.";
01226     case NERR_LogonScriptError:
01227       return "An error occurred while loading or running the logon script.";
01228     case NERR_StandaloneLogon:
01229       return "The logon server was not specified. Your computer will be logged on as STANDALONE.";
01230     case NERR_LogonServerNotFound:
01231       return "The logon server could not be found.";
01232     case NERR_LogonDomainExists:
01233       return "There is already a logon domain for this computer.";
01234     case NERR_NonValidatedLogon:
01235       return "The logon server could not validate the logon.";
01236     case NERR_ACFNotFound:
01237       return "The security database could not be found.";
01238     case NERR_GroupNotFound:
01239       return "The group name could not be found.";
01240     case NERR_UserNotFound:
01241       return "The user name could not be found.";
01242     case NERR_ResourceNotFound:
01243       return "The resource name could not be found.";
01244     case NERR_GroupExists:
01245       return "The group already exists.";
01246     case NERR_UserExists:
01247       return "The user account already exists.";
01248     case NERR_ResourceExists:
01249       return "The resource permission list already exists.";
01250     case NERR_NotPrimary:
01251       return "This operation is only allowed on the primary domain controller of the domain.";
01252     case NERR_ACFNotLoaded:
01253       return "The security database has not been started.";
01254     case NERR_ACFNoRoom:
01255       return "There are too many names in the user accounts database.";
01256     case NERR_ACFFileIOFail:
01257       return "A disk I/O failure occurred.";
01258     case NERR_ACFTooManyLists:
01259       return "The limit of 64 entries per resource was exceeded.";
01260     case NERR_UserLogon:
01261       return "Deleting a user with a session is not allowed.";
01262     case NERR_ACFNoParent:
01263       return "The parent directory could not be located.";
01264     case NERR_CanNotGrowSegment:
01265       return "Unable to add to the security database session cache segment.";
01266     case NERR_SpeGroupOp:
01267       return "This operation is not allowed on this special group.";
01268     case NERR_NotInCache:
01269       return "This user is not cached in user accounts database session cache.";
01270     case NERR_UserInGroup:
01271       return "The user already belongs to this group.";
01272     case NERR_UserNotInGroup:
01273       return "The user does not belong to this group.";
01274     case NERR_AccountUndefined:
01275       return "This user account is undefined.";
01276     case NERR_AccountExpired:
01277       return "This user account has expired.";
01278     case NERR_InvalidWorkstation:
01279       return "The user is not allowed to log on from this workstation.";
01280     case NERR_InvalidLogonHours:
01281       return "The user is not allowed to log on at this time.";
01282     case NERR_PasswordExpired:
01283       return "The password of this user has expired.";
01284     case NERR_PasswordCantChange:
01285       return "The password of this user cannot change.";
01286     case NERR_PasswordHistConflict:
01287       return "This password cannot be used now.";
01288     case NERR_PasswordTooShort:
01289       return "The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements.";
01290     case NERR_PasswordTooRecent:
01291       return "The password of this user is too recent to change.";
01292     case NERR_InvalidDatabase:
01293       return "The security database is corrupted.";
01294     case NERR_DatabaseUpToDate:
01295       return "No updates are necessary to this replicant network/local security database.";
01296     case NERR_SyncRequired:
01297       return "This replicant database is outdated; synchronization is required.";
01298     case NERR_UseNotFound:
01299       return "The network connection could not be found.";
01300     case NERR_BadAsgType:
01301       return "This asg_type is invalid.";
01302     case NERR_DeviceIsShared:
01303       return "This device is currently being shared.";
01304     case NERR_NoComputerName:
01305       return "The computer name could not be added as a message alias. The name may already exist on the network.";
01306     case NERR_MsgAlreadyStarted:
01307       return "The Messenger service is already started.";
01308     case NERR_MsgInitFailed:
01309       return "The Messenger service failed to start.";
01310     case NERR_NameNotFound:
01311       return "The message alias could not be found on the network.";
01312     case NERR_AlreadyForwarded:
01313       return "This message alias has already been forwarded.";
01314     case NERR_AddForwarded:
01315       return "This message alias has been added but is still forwarded.";
01316     case NERR_AlreadyExists:
01317       return "This message alias already exists locally.";
01318     case NERR_TooManyNames:
01319       return "The maximum number of added message aliases has been exceeded.";
01320     case NERR_DelComputerName:
01321       return "The computer name could not be deleted.";
01322     case NERR_LocalForward:
01323       return "Messages cannot be forwarded back to the same workstation.";
01324     case NERR_GrpMsgProcessor:
01325       return "An error occurred in the domain message processor.";
01326     case NERR_PausedRemote:
01327       return "The message was sent, but the recipient has paused the Messenger service.";
01328     case NERR_BadReceive:
01329       return "The message was sent but not received.";
01330     case NERR_NameInUse:
01331       return "The message alias is currently in use. Try again later.";
01332     case NERR_MsgNotStarted:
01333       return "The Messenger service has not been started.";
01334     case NERR_NotLocalName:
01335       return "The name is not on the local computer.";
01336     case NERR_NoForwardName:
01337       return "The forwarded message alias could not be found on the network.";
01338     case NERR_RemoteFull:
01339       return "The message alias table on the remote station is full.";
01340     case NERR_NameNotForwarded:
01341       return "Messages for this alias are not currently being forwarded.";
01342     case NERR_TruncatedBroadcast:
01343       return "The broadcast message was truncated.";
01344     case NERR_InvalidDevice:
01345       return "This is an invalid device name.";
01346     case NERR_WriteFault:
01347       return "A write fault occurred.";
01348     case NERR_DuplicateName:
01349       return "A duplicate message alias exists on the network.";
01350     case NERR_DeleteLater:
01351       return "@W This message alias will be deleted later.";
01352     case NERR_IncompleteDel:
01353       return "The message alias was not successfully deleted from all networks.";
01354     case NERR_MultipleNets:
01355       return "This operation is not supported on computers with multiple networks.";
01356     case NERR_NetNameNotFound:
01357       return "This shared resource does not exist.";
01358     case NERR_DeviceNotShared:
01359       return "This device is not shared.";
01360     case NERR_ClientNameNotFound:
01361       return "A session does not exist with that computer name.";
01362     case NERR_FileIdNotFound:
01363       return "There is not an open file with that identification number.";
01364     case NERR_ExecFailure:
01365       return "A failure occurred when executing a remote administration command.";
01366     case NERR_TmpFile:
01367       return "A failure occurred when opening a remote temporary file.";
01368     case NERR_TooMuchData:
01369       return "The data returned from a remote administration command has been truncated to 64K.";
01370     case NERR_DeviceShareConflict:
01371       return "This device cannot be shared as both a spooled and a non-spooled resource.";
01372     case NERR_BrowserTableIncomplete:
01373       return "The information in the list of servers may be incorrect.";
01374     case NERR_NotLocalDomain:
01375       return "The computer is not active in this domain.";
01376 #ifdef NERR_IsDfsShare
01377 
01378     case NERR_IsDfsShare:
01379       return "The share must be removed from the Distributed File System before it can be deleted.";
01380 #endif
01381 
01382     case NERR_DevInvalidOpCode:
01383       return "The operation is invalid for this device.";
01384     case NERR_DevNotFound:
01385       return "This device cannot be shared.";
01386     case NERR_DevNotOpen:
01387       return "This device was not open.";
01388     case NERR_BadQueueDevString:
01389       return "This device name list is invalid.";
01390     case NERR_BadQueuePriority:
01391       return "The queue priority is invalid.";
01392     case NERR_NoCommDevs:
01393       return "There are no shared communication devices.";
01394     case NERR_QueueNotFound:
01395       return "The queue you specified does not exist.";
01396     case NERR_BadDevString:
01397       return "This list of devices is invalid.";
01398     case NERR_BadDev:
01399       return "The requested device is invalid.";
01400     case NERR_InUseBySpooler:
01401       return "This device is already in use by the spooler.";
01402     case NERR_CommDevInUse:
01403       return "This device is already in use as a communication device.";
01404     case NERR_InvalidComputer:
01405       return "This computer name is invalid.";
01406     case NERR_MaxLenExceeded:
01407       return "The string and prefix specified are too long.";
01408     case NERR_BadComponent:
01409       return "This path component is invalid.";
01410     case NERR_CantType:
01411       return "Could not determine the type of input.";
01412     case NERR_TooManyEntries:
01413       return "The buffer for types is not big enough.";
01414     case NERR_ProfileFileTooBig:
01415       return "Profile files cannot exceed 64K.";
01416     case NERR_ProfileOffset:
01417       return "The start offset is out of range.";
01418     case NERR_ProfileCleanup:
01419       return "The system cannot delete current connections to network resources.";
01420     case NERR_ProfileUnknownCmd:
01421       return "The system was unable to parse the command line in this file.";
01422     case NERR_ProfileLoadErr:
01423       return "An error occurred while loading the profile file.";
01424     case NERR_ProfileSaveErr:
01425       return "@W Errors occurred while saving the profile file. The profile was partially saved.";
01426     case NERR_LogOverflow:
01427       return "Log file %1 is full.";
01428     case NERR_LogFileChanged:
01429       return "This log file has changed between reads.";
01430     case NERR_LogFileCorrupt:
01431       return "Log file %1 is corrupt.";
01432     case NERR_SourceIsDir:
01433       return "The source path cannot be a directory.";
01434     case NERR_BadSource:
01435       return "The source path is illegal.";
01436     case NERR_BadDest:
01437       return "The destination path is illegal.";
01438     case NERR_DifferentServers:
01439       return "The source and destination paths are on different servers.";
01440     case NERR_RunSrvPaused:
01441       return "The Run server you requested is paused.";
01442     case NERR_ErrCommRunSrv:
01443       return "An error occurred when communicating with a Run server.";
01444     case NERR_ErrorExecingGhost:
01445       return "An error occurred when starting a background process.";
01446     case NERR_ShareNotFound:
01447       return "The shared resource you are connected to could not be found.";
01448     case NERR_InvalidLana:
01449       return "The LAN adapter number is invalid.";
01450     case NERR_OpenFiles:
01451       return "There are open files on the connection.";
01452     case NERR_ActiveConns:
01453       return "Active connections still exist.";
01454     case NERR_BadPasswordCore:
01455       return "This share name or password is invalid.";
01456     case NERR_DevInUse:
01457       return "The device is being accessed by an active process.";
01458     case NERR_LocalDrive:
01459       return "The drive letter is in use locally.";
01460     case NERR_AlertExists:
01461       return "The specified client is already registered for the specified event.";
01462     case NERR_TooManyAlerts:
01463       return "The alert table is full.";
01464     case NERR_NoSuchAlert:
01465       return "An invalid or nonexistent alert name was raised.";
01466     case NERR_BadRecipient:
01467       return "The alert recipient is invalid.";
01468     case NERR_AcctLimitExceeded:
01469       return "A user's session with this server has been deleted.";
01470     case NERR_InvalidLogSeek:
01471       return "The log file does not contain the requested record number.";
01472     case NERR_BadUasConfig:
01473       return "The user accounts database is not configured correctly.";
01474     case NERR_InvalidUASOp:
01475       return "This operation is not permitted when the Netlogon service is running.";
01476     case NERR_LastAdmin:
01477       return "This operation is not allowed on the last administrative account.";
01478     case NERR_DCNotFound:
01479       return "Could not find domain controller for this domain.";
01480     case NERR_LogonTrackingError:
01481       return "Could not set logon information for this user.";
01482     case NERR_NetlogonNotStarted:
01483       return "The Netlogon service has not been started.";
01484     case NERR_CanNotGrowUASFile:
01485       return "Unable to add to the user accounts database.";
01486     case NERR_TimeDiffAtDC:
01487       return "This server's clock is not synchronized with the primary domain controller's clock.";
01488     case NERR_PasswordMismatch:
01489       return "A password mismatch has been detected.";
01490     case NERR_NoSuchServer:
01491       return "The server identification does not specify a valid server.";
01492     case NERR_NoSuchSession:
01493       return "The session identification does not specify a valid session.";
01494     case NERR_NoSuchConnection:
01495       return "The connection identification does not specify a valid connection.";
01496     case NERR_TooManyServers:
01497       return "There is no space for another entry in the table of available servers.";
01498     case NERR_TooManySessions:
01499       return "The server has reached the maximum number of sessions it supports.";
01500     case NERR_TooManyConnections:
01501       return "The server has reached the maximum number of connections it supports.";
01502     case NERR_TooManyFiles:
01503       return "The server cannot open more files because it has reached its maximum number.";
01504     case NERR_NoAlternateServers:
01505       return "There are no alternate servers registered on this server.";
01506     case NERR_TryDownLevel:
01507       return "Try down-level (remote admin protocol) version of API instead.";
01508     case NERR_UPSDriverNotStarted:
01509       return "The UPS driver could not be accessed by the UPS service.";
01510     case NERR_UPSInvalidConfig:
01511       return "The UPS service is not configured correctly.";
01512     case NERR_UPSInvalidCommPort:
01513       return "The UPS service could not access the specified Comm Port.";
01514     case NERR_UPSSignalAsserted:
01515       return "The UPS indicated a line fail or low battery situation. Service not started.";
01516     case NERR_UPSShutdownFailed:
01517       return "The UPS service failed to perform a system shut down.";
01518     case NERR_BadDosRetCode:
01519       return "The program below returned an MS-DOS error code:";
01520     case NERR_ProgNeedsExtraMem:
01521       return "The program below needs more memory:";
01522     case NERR_BadDosFunction:
01523       return "The program below called an unsupported MS-DOS function:";
01524     case NERR_RemoteBootFailed:
01525       return "The workstation failed to boot.";
01526     case NERR_BadFileCheckSum:
01527       return "The file below is corrupt.";
01528     case NERR_NoRplBootSystem:
01529       return "No loader is specified in the boot-block definition file.";
01530     case NERR_RplLoadrNetBiosErr:
01531       return "NetBIOS returned an error:      The NCB and SMB are dumped above.";
01532     case NERR_RplLoadrDiskErr:
01533       return "A disk I/O error occurred.";
01534     case NERR_ImageParamErr:
01535       return "Image parameter substitution failed.";
01536     case NERR_TooManyImageParams:
01537       return "Too many image parameters cross disk sector boundaries.";
01538     case NERR_NonDosFloppyUsed:
01539       return "The image was not generated from an MS-DOS diskette formatted with /S.";
01540     case NERR_RplBootRestart:
01541       return "Remote boot will be restarted later.";
01542     case NERR_RplSrvrCallFailed:
01543       return "The call to the Remoteboot server failed.";
01544     case NERR_CantConnectRplSrvr:
01545       return "Cannot connect to the Remoteboot server.";
01546     case NERR_CantOpenImageFile:
01547       return "Cannot open image file on the Remoteboot server.";
01548     case NERR_CallingRplSrvr:
01549       return "Connecting to the Remoteboot server...";
01550     case NERR_StartingRplBoot:
01551       return "Connecting to the Remoteboot server...";
01552     case NERR_RplBootServiceTerm:
01553       return "Remote boot service was stopped; check the error log for the cause of the problem.";
01554     case NERR_RplBootStartFailed:
01555       return "Remote boot startup failed; check the error log for the cause of the problem.";
01556     case NERR_RPL_CONNECTED:
01557       return "A second connection to a Remoteboot resource is not allowed.";
01558     case NERR_BrowserConfiguredToNotRun:
01559       return "The browser service was configured with MaintainServerList=No.";
01560     case NERR_RplNoAdaptersStarted:
01561       return "Service failed to start since none of the network adapters started with this service.";
01562     case NERR_RplBadRegistry:
01563       return "Service failed to start due to bad startup information in the registry.";
01564     case NERR_RplBadDatabase:
01565       return "Service failed to start because its database is absent or corrupt.";
01566     case NERR_RplRplfilesShare:
01567       return "Service failed to start because RPLFILES share is absent.";
01568     case NERR_RplNotRplServer:
01569       return "Service failed to start because RPLUSER group is absent.";
01570     case NERR_RplCannotEnum:
01571       return "Cannot enumerate service records.";
01572     case NERR_RplWkstaInfoCorrupted:
01573       return "Workstation record information has been corrupted.";
01574     case NERR_RplWkstaNotFound:
01575       return "Workstation record was not found.";
01576     case NERR_RplWkstaNameUnavailable:
01577       return "Workstation name is in use by some other workstation.";
01578     case NERR_RplProfileInfoCorrupted:
01579       return "Profile record information has been corrupted.";
01580     case NERR_RplProfileNotFound:
01581       return "Profile record was not found.";
01582     case NERR_RplProfileNameUnavailable:
01583       return "Profile name is in use by some other profile.";
01584     case NERR_RplProfileNotEmpty:
01585       return "There are workstations using this profile.";
01586     case NERR_RplConfigInfoCorrupted:
01587       return "Configuration record information has been corrupted.";
01588     case NERR_RplConfigNotFound:
01589       return "Configuration record was not found.";
01590     case NERR_RplAdapterInfoCorrupted:
01591       return "Adapter ID record information has been corrupted.";
01592     case NERR_RplInternal:
01593       return "An internal service error has occurred.";
01594     case NERR_RplVendorInfoCorrupted:
01595       return "Vendor ID record information has been corrupted.";
01596     case NERR_RplBootInfoCorrupted:
01597       return "Boot block record information has been corrupted.";
01598     case NERR_RplWkstaNeedsUserAcct:
01599       return "The user account for this workstation record is missing.";
01600     case NERR_RplNeedsRPLUSERAcct:
01601       return "The RPLUSER local group could not be found.";
01602     case NERR_RplBootNotFound:
01603       return "Boot block record was not found.";
01604     case NERR_RplIncompatibleProfile:
01605       return "Chosen profile is incompatible with this workstation.";
01606     case NERR_RplAdapterNameUnavailable:
01607       return "Chosen network adapter ID is in use by some other workstation.";
01608     case NERR_RplConfigNotEmpty:
01609       return "There are profiles using this configuration.";
01610     case NERR_RplBootInUse:
01611       return "There are workstations, profiles, or configurations using this boot block.";
01612     case NERR_RplBackupDatabase:
01613       return "Service failed to backup Remoteboot database.";
01614     case NERR_RplAdapterNotFound:
01615       return "Adapter record was not found.";
01616     case NERR_RplVendorNotFound:
01617       return "Vendor record was not found.";
01618     case NERR_RplVendorNameUnavailable:
01619       return "Vendor name is in use by some other vendor record.";
01620     case NERR_RplBootNameUnavailable:
01621       return "(boot name, vendor ID) is in use by some other boot block record.";
01622     case NERR_RplConfigNameUnavailable:
01623       return "Configuration name is in use by some other configuration.";
01624     case NERR_DfsInternalCorruption:
01625       return "The internal database maintained by the Dfs service is corrupt.";
01626     case NERR_DfsVolumeDataCorrupt:
01627       return "One of the records in the internal Dfs database is corrupt.";
01628     case NERR_DfsNoSuchVolume:
01629       return "There is no DFS name whose entry path matches the input Entry Path.";
01630     case NERR_DfsVolumeAlreadyExists:
01631       return "A root or link with the given name already exists.";
01632     case NERR_DfsAlreadyShared:
01633       return "The server share specified is already shared in the Dfs.";
01634     case NERR_DfsNoSuchShare:
01635       return "The indicated server share does not support the indicated DFS namespace.";
01636     case NERR_DfsNotALeafVolume:
01637       return "The operation is not valid on this portion of the namespace.";
01638     case NERR_DfsLeafVolume:
01639       return "The operation is not valid on this portion of the namespace.";
01640     case NERR_DfsVolumeHasMultipleServers:
01641       return "The operation is ambiguous because the link has multiple servers.";
01642     case NERR_DfsCantCreateJunctionPoint:
01643       return "Unable to create a link.";
01644     case NERR_DfsServerNotDfsAware:
01645       return "The server is not Dfs Aware.";
01646     case NERR_DfsBadRenamePath:
01647       return "The specified rename target path is invalid.";
01648     case NERR_DfsVolumeIsOffline:
01649       return "The specified DFS link is offline.";
01650     case NERR_DfsNoSuchServer:
01651       return "The specified server is not a server for this link.";
01652     case NERR_DfsCyclicalName:
01653       return "A cycle in the Dfs name was detected.";
01654     case NERR_DfsNotSupportedInServerDfs:
01655       return "The operation is not supported on a server-based Dfs.";
01656     case NERR_DfsDuplicateService:
01657       return "This link is already supported by the specified server-share.";
01658     case NERR_DfsCantRemoveLastServerShare:
01659       return "Can't remove the last server-share supporting this root or link.";
01660     case NERR_DfsVolumeIsInterDfs:
01661       return "The operation is not supported for an Inter-DFS link.";
01662     case NERR_DfsInconsistent:
01663       return "The internal state of the Dfs Service has become inconsistent.";
01664     case NERR_DfsServerUpgraded:
01665       return "The Dfs Service has been installed on the specified server.";
01666     case NERR_DfsDataIsIdentical:
01667       return "The Dfs data being reconciled is identical.";
01668     case NERR_DfsCantRemoveDfsRoot:
01669       return "The DFS root cannot be deleted. Uninstall DFS if required.";
01670     case NERR_DfsChildOrParentInDfs:
01671       return "A child or parent directory of the share is already in a Dfs.";
01672     case NERR_DfsInternalError:
01673       return "Dfs internal error.";
01674       /* the following are not defined in mingw */
01675 #if 0
01676 
01677     case NERR_SetupAlreadyJoined:
01678       return "This machine is already joined to a domain.";
01679     case NERR_SetupNotJoined:
01680       return "This machine is not currently joined to a domain.";
01681     case NERR_SetupDomainController:
01682       return "This machine is a domain controller and cannot be unjoined from a domain.";
01683     case NERR_DefaultJoinRequired:
01684       return "The destination domain controller does not support creating machine accounts in OUs.";
01685     case NERR_InvalidWorkgroupName:
01686       return "The specified workgroup name is invalid.";
01687     case NERR_NameUsesIncompatibleCodePage:
01688       return "The specified computer name is incompatible with the default language used on the domain controller.";
01689     case NERR_ComputerAccountNotFound:
01690       return "The specified computer account could not be found.";
01691     case NERR_PersonalSku:
01692       return "This version of Windows cannot be joined to a domain.";
01693     case NERR_PasswordMustChange:
01694       return "The password must change at the next logon.";
01695     case NERR_AccountLockedOut:
01696       return "The account is locked out.";
01697     case NERR_PasswordTooLong:
01698       return "The password is too long.";
01699     case NERR_PasswordNotComplexEnough:
01700       return "The password does not meet the complexity policy.";
01701     case NERR_PasswordFilterError:
01702       return "The password does not meet the requirements of the password filter DLLs.";
01703 #endif
01704 
01705     }
01706   msg = strerror (error_number);
01707   if (msg == NULL)
01708     msg = "unknown";
01709 
01710   return msg;
01711 #endif //DBUS_WINCE
01712 }

Generated on Wed Aug 29 12:15:04 2007 for D-Bus by  doxygen 1.5.2