- /* The following creates a seed for the session key generator
- based on a collection of volatile and environment-specific
- information unlikely to be vulnerable (as a whole) to an
- exhaustive search attack. If one of these items isn't
- available on your machine, replace it with something
- equivalent or, if you like, just delete it. */
-
- sprintf(s + strlen(s), "%lu", (unsigned long) getpid());
- sprintf(s + strlen(s), "%lu", (unsigned long) getppid());
- getcwd(s + strlen(s), 256);
- sprintf(s + strlen(s), "%lu", (unsigned long) clock());
- sprintf(s + strlen(s), "%lu", (unsigned long) time(NULL));
-#ifdef Solaris
- sysinfo(SI_HW_SERIAL,s + strlen(s), 12);
-#endif
-#ifdef HAVE_GETHOSTID
- sprintf(s + strlen(s), "%lu", (unsigned long) gethostid());
-#endif
-#ifdef HAVE_GETDOMAINNAME
- getdomainname(s + strlen(s), 256);
-#endif
- gethostname(s + strlen(s), 256);
- sprintf(s + strlen(s), "%u", (unsigned)getuid());
- sprintf(s + strlen(s), "%u", (unsigned)getgid());
- MD5Init(&md5c);
- MD5Update(&md5c, (unsigned char *)s, strlen(s));
- MD5Final(md5key, &md5c);
- sprintf(s + strlen(s), "%lu", (unsigned long) ((time(NULL) + 65121) ^ 0x375F));
- MD5Init(&md5c);
- MD5Update(&md5c, (unsigned char *)s, strlen(s));
- MD5Final(md5key1, &md5c);
-#define nextrand (md5key[j] ^ md5key1[j])
- if (mode) {
- for (j = k = 0; j < 16; j++) {
- unsigned char rb = nextrand;
+ if (wd == NULL) {
+ Emsg0(M_ERROR_TERM, 0, _("Working directory not defined. Cannot continue.\n"));
+ }
+ if (stat(wd, &stat_buf) != 0) {
+ Emsg1(M_ERROR_TERM, 0, _("Working Directory: \"%s\" not found. Cannot continue.\n"),
+ wd);
+ }
+ if (!S_ISDIR(stat_buf.st_mode)) {
+ Emsg1(M_ERROR_TERM, 0, _("Working Directory: \"%s\" is not a directory. Cannot continue.\n"),
+ wd);
+ }
+ working_directory = wd; /* set global */
+}