spc-error.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * $TOG: spc-error.c /main/10 1998/04/10 08:27:30 mgreess $
  25. * Language: C
  26. *
  27. * (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
  28. *
  29. * (c) Copyright 1993, 1994 Hewlett-Packard Company *
  30. * (c) Copyright 1993, 1994 International Business Machines Corp. *
  31. * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
  32. * (c) Copyright 1993, 1994 Novell, Inc. *
  33. */
  34. #include <Dt/UserMsg.h>
  35. #include <bms/sbport.h> /* NOTE: sbport.h must be the first include. */
  36. #include <errno.h>
  37. #include <stdarg.h>
  38. #include <SPC/spcP.h>
  39. #include <bms/MemoryMgr.h> /* NOTE: sbport.h must be the first include. */
  40. #define X_INCLUDE_TIME_H
  41. #define XOS_USE_XT_LOCKING
  42. #include <X11/Xos_r.h>
  43. #include "DtSvcLock.h"
  44. /*
  45. * Log file information (routines near bottom of file)
  46. */
  47. #define TEMPLATE_EXTENSION (XeString)".XXXXXX" /* For mktemp(3c) */
  48. XeChar spc_logfile[MAXPATHLEN+1];
  49. XeChar spc_logging = FALSE;
  50. /* FILE *spc_logF = NULL; -- to bmsglob.c */
  51. int spc_logfd = 0;
  52. /* This is the SPC error number variable */
  53. /* ------------------------------------- */
  54. /* int XeSPCErrorNumber = NULL; --- now in bmsglob.c */
  55. /*------------------------------------------------------------------------+*/
  56. static XeString
  57. err_mnemonic(unsigned int errn, char *buff)
  58. /*------------------------------------------------------------------------+*/
  59. {
  60. /* Since there is currently no standard way to get an err number */
  61. /* mnenonic from the system, we do it the hard way. We can't even */
  62. /* use a table as the actual numeric values may differ on machines. */
  63. /* Another potential problem is if one of these gets passed across */
  64. /* a network connection from a different type of machine that has */
  65. /* values that differ than the machine this routine runs on, we */
  66. /* could have problems. I don't think anycode does that now. */
  67. /* ---------------------------------------------------------------- */
  68. XeString s;
  69. switch (errn) {
  70. /* These are all in POSIX 1003.1 and/or X/Open XPG3 */
  71. /* ---------------------------------------------------- */
  72. case EPERM : s = (XeString)"EPERM"; break;
  73. case ENOENT : s = (XeString)"ENOENT"; break;
  74. case ESRCH : s = (XeString)"ESRCH"; break;
  75. case EINTR : s = (XeString)"EINTR"; break;
  76. case EIO : s = (XeString)"EIO"; break;
  77. case ENXIO : s = (XeString)"ENXIO"; break;
  78. case E2BIG : s = (XeString)"E2BIG"; break;
  79. case ENOEXEC : s = (XeString)"ENOEXEC"; break;
  80. case EBADF : s = (XeString)"EBADF"; break;
  81. case ECHILD : s = (XeString)"ECHILD"; break;
  82. case EAGAIN : s = (XeString)"EAGAIN"; break;
  83. case ENOMEM : s = (XeString)"ENOMEM"; break;
  84. case EACCES : s = (XeString)"EACCES"; break;
  85. case EFAULT : s = (XeString)"EFAULT"; break;
  86. case ENOTBLK : s = (XeString)"ENOTBLK"; break;
  87. case EBUSY : s = (XeString)"EBUSY"; break;
  88. case EEXIST : s = (XeString)"EEXIST"; break;
  89. case EXDEV : s = (XeString)"EXDEV"; break;
  90. case ENODEV : s = (XeString)"ENODEV"; break;
  91. case ENOTDIR : s = (XeString)"ENOTDIR"; break;
  92. case EISDIR : s = (XeString)"EISDIR"; break;
  93. case EINVAL : s = (XeString)"EINVAL"; break;
  94. case ENFILE : s = (XeString)"ENFILE"; break;
  95. case EMFILE : s = (XeString)"EMFILE"; break;
  96. case ENOTTY : s = (XeString)"ENOTTY"; break;
  97. case ETXTBSY : s = (XeString)"ETXTBSY"; break;
  98. case EFBIG : s = (XeString)"EFBIG"; break;
  99. case ENOSPC : s = (XeString)"ENOSPC"; break;
  100. case ESPIPE : s = (XeString)"ESPIPE"; break;
  101. case EROFS : s = (XeString)"EROFS"; break;
  102. case EMLINK : s = (XeString)"EMLINK"; break;
  103. case EPIPE : s = (XeString)"EPIPE"; break;
  104. case ENOMSG : s = (XeString)"ENOMSG"; break;
  105. case EIDRM : s = (XeString)"EIDRM"; break;
  106. case EDEADLK : s = (XeString)"EDEADLK"; break;
  107. case ENOLCK : s = (XeString)"ENOLCK"; break;
  108. #ifndef __aix
  109. case ENOTEMPTY : s = (XeString)"ENOTEMPTY"; break;
  110. #endif
  111. case ENAMETOOLONG : s = (XeString)"ENAMETOOLONG"; break;
  112. case ENOSYS : s = (XeString)"ENOSYS"; break;
  113. /* You could include machine specific stuff here ... */
  114. /* ---------------------------------------------------- */
  115. /* ---------------------------------------------------- */
  116. default : s = XeString_NULL; break;
  117. }
  118. if (s)
  119. sprintf(buff, "%s (%d)",s,errn);
  120. else
  121. sprintf(buff, "(%d)",errn);
  122. return buff;
  123. }
  124. /*----------------------------------------------------------------------+*/
  125. XeString SPC_copy_string(XeString str)
  126. /*----------------------------------------------------------------------+*/
  127. {
  128. int len;
  129. XeString tmp_str;
  130. if(!str)
  131. return(XeString_NULL);
  132. len=strlen(str);
  133. tmp_str=(XeString)XeMalloc(len+1);
  134. strcpy(tmp_str, str);
  135. return(tmp_str);
  136. }
  137. /*----------------------------------------------------------------------+*/
  138. void SPC_Error (int error, ...)
  139. /*----------------------------------------------------------------------+*/
  140. {
  141. va_list ap;
  142. SPCError *err;
  143. XeChar *buffer;
  144. XeString arg1;
  145. long arg2;
  146. XeChar buff[40];
  147. err=SPC_Lookup_Error(error);
  148. if(!err)
  149. return;
  150. if(err->text) {
  151. free(err->text);
  152. err->text = NULL;
  153. }
  154. va_start(ap, error); /** Start varargs **/
  155. arg1=va_arg(ap, XeString);
  156. if (arg1)
  157. {
  158. /* The argument on the stack may be holding an int or a char pointer. */
  159. /* Always popping off a long into the value of arg2 works fine */
  160. /* because the subsequent call to sprintf does the proper conversion via */
  161. /* "err->format". */
  162. arg2=va_arg(ap, long);
  163. }
  164. else
  165. {
  166. arg1 = XeString_Empty;
  167. arg2 = 0;
  168. }
  169. buffer = (XeChar*) malloc(sizeof(XeChar) * SPC_BUFSIZ);
  170. if (buffer)
  171. {
  172. sprintf(buffer, err->format, arg1, arg2);
  173. err->text=SPC_copy_string(buffer);
  174. free(buffer);
  175. }
  176. va_end(ap); /** End varargs **/
  177. _DtSvcProcessLock();
  178. XeSPCErrorNumber=error;
  179. if (SPC_who_am_i == SPC_I_AM_A_DAEMON){
  180. SPC_Format_Log((XeString)"DTSPCD error (%d): %s",
  181. XeSPCErrorNumber, err->text);
  182. if (err->use_errno){
  183. XeString errname;
  184. XeString errmsg;
  185. unsigned int errn = errno;
  186. errname = err_mnemonic(errn, buff);
  187. if (!(errmsg = strerror(errn)))
  188. errmsg = (XeString) "unknown";
  189. SPC_Format_Log((XeString)" [%s] %s", errname, errmsg);
  190. }
  191. if(err->severity == XeFatalError || err->severity == XeInternalError) {
  192. SPC_Format_Log((XeString)"Exiting server ...");
  193. SPC_Close_Log();
  194. _DtSvcProcessUnlock();
  195. exit (3);
  196. }
  197. }
  198. else
  199. _DtSimpleError(XeProgName, XeError, XeString_NULL, err->text);
  200. _DtSvcProcessUnlock();
  201. return;
  202. }
  203. /*
  204. * Log file routines
  205. *
  206. * Note: Current restriction of only one log file open at a time.
  207. */
  208. /*----------------------------------------------------------------------+*/
  209. int
  210. SPC_Make_Log_Filename(XeString name,
  211. int unique) /* When TRUE, make name unique */
  212. /*----------------------------------------------------------------------+*/
  213. {
  214. /* Make a log filename based on the passed name (and perhaps process id) */
  215. XeString cp;
  216. XeString log_file_path = NULL;
  217. _DtSvcProcessLock();
  218. /* first build the log file path */
  219. if (!name || !*name) {
  220. log_file_path = XeSBTempPath((XeString)"DTSPCD_log");
  221. strcpy(spc_logfile, log_file_path);
  222. }
  223. else {
  224. if (strlen(name) > MAXPATHLEN)
  225. _DtSimpleError(XeProgName, XeInternalError, XeString_NULL,
  226. (XeString)"String too long in DTSPCD_Make_Log_Filename()");
  227. strcpy(spc_logfile, name);
  228. }
  229. if (unique) {
  230. /* Add the extension. No strlen checking is done */
  231. strcat(spc_logfile, TEMPLATE_EXTENSION);
  232. cp = (XeString) mktemp(spc_logfile);
  233. if (!cp || !*cp) {
  234. /* Sorry, but this is the best we can do */
  235. strcpy(spc_logfile, (log_file_path) ? log_file_path : name);
  236. }
  237. }
  238. /* free the strings allocated for the path */
  239. if (log_file_path) XeFree(log_file_path);
  240. _DtSvcProcessUnlock();
  241. return TRUE;
  242. }
  243. /*----------------------------------------------------------------------+*/
  244. int
  245. SPC_Open_Log(XeString filename,
  246. int unique) /* When TRUE, make filename unique */
  247. /*----------------------------------------------------------------------+*/
  248. {
  249. /* Open the SPC log file */
  250. /* Use the filename if one was passed to make a log filename */
  251. SPC_Make_Log_Filename(filename, unique);
  252. /* Open the logfile */
  253. _DtSvcProcessLock();
  254. spc_logF = fopen(spc_logfile, "a+");
  255. if (!spc_logF) {
  256. _DtSvcProcessUnlock();
  257. return(SPC_ERROR);
  258. }
  259. spc_logging = TRUE;
  260. SPC_Format_Log((XeString)"*** DTSPCD logging started, file: `%s'", spc_logfile);
  261. _DtSvcProcessUnlock();
  262. return(TRUE);
  263. }
  264. /*----------------------------------------------------------------------+*/
  265. int
  266. SPC_Close_Log(void)
  267. /*----------------------------------------------------------------------+*/
  268. {
  269. /* Close the current log file */
  270. SPC_Format_Log((XeString)"*** DTSPCD logging stopped");
  271. _DtSvcProcessLock();
  272. if (spc_logF) {
  273. fclose(spc_logF);
  274. }
  275. spc_logfd = 0;
  276. spc_logF = NULL;
  277. spc_logging = FALSE;
  278. _DtSvcProcessUnlock();
  279. return(TRUE);
  280. }
  281. /*----------------------------------------------------------------------+*/
  282. int
  283. SPC_Write_Log(XeString str)
  284. /*----------------------------------------------------------------------+*/
  285. {
  286. /* Write the passed message to the log file */
  287. time_t t;
  288. _Xctimeparams ctime_buf;
  289. char *result;
  290. _DtSvcProcessLock();
  291. if (spc_logging && spc_logF) {
  292. t = time(NULL);
  293. result = _XCtime(&t, ctime_buf);
  294. fprintf(spc_logF, "%s: %s", str, result);
  295. fflush(spc_logF);
  296. }
  297. _DtSvcProcessUnlock();
  298. return(TRUE);
  299. }
  300. /*----------------------------------------------------------------------+*/
  301. int SPC_Format_Log (XeString format, ...)
  302. /*----------------------------------------------------------------------+*/
  303. {
  304. /* Format the passed message to the log file */
  305. va_list args;
  306. time_t t;
  307. _Xctimeparams ctime_buf;
  308. char *result;
  309. _DtSvcProcessLock();
  310. if (spc_logging && spc_logF) {
  311. /* First the message */
  312. va_start(args, format);
  313. vfprintf(spc_logF, format, args);
  314. va_end(args);
  315. /* Now a time stamp */
  316. t = time(NULL);
  317. result = _XCtime(&t, ctime_buf);
  318. fprintf(spc_logF, ": %s", result);
  319. fflush(spc_logF);
  320. }
  321. _DtSvcProcessUnlock();
  322. return(TRUE);
  323. }
  324. /*
  325. **
  326. ** This next routine used to be such a nice little guy... Once upon a
  327. ** time I had all the error messages in a very
  328. ** compact representation. It was a vector of SPCError structures.
  329. ** When I wanted to go from the integer representation of an error to
  330. ** its textual form, I simply did a table lookup. Unfortunately,
  331. ** that method did not work at all well with the NLS scheme cooked up
  332. ** by the Excalibur team. This scheme was nice for programs which
  333. ** just had the strings in the text. It basically searched the
  334. ** source program for a string with a funny symbol and replaced it
  335. ** with a function call. Well, to make a long story short, I decided
  336. ** to go with that scheme. Thus this function.
  337. **
  338. */
  339. SPCError spc_error_struct;
  340. /*----------------------------------------------------------------------+*/
  341. SPCError *SPC_Lookup_Error(int errornum)
  342. /*----------------------------------------------------------------------+*/
  343. {
  344. _DtSvcProcessLock();
  345. switch (errornum) {
  346. case SPC_Out_Of_Memory:
  347. spc_error_struct.format = (XeString) "><Unable to allocate memory for internal SPC operation\n Perhaps you need to add more swap space to the system";
  348. spc_error_struct.severity = XeFatalError;
  349. spc_error_struct.use_errno = FALSE;
  350. break;
  351. case SPC_Bad_Argument:
  352. spc_error_struct.format = (XeString) "><Bad argument to DTSPCD call";
  353. spc_error_struct.severity = XeError;
  354. spc_error_struct.use_errno = FALSE;
  355. break;
  356. case SPC_Active_Channel:
  357. spc_error_struct.format = (XeString) "><Channel already active";
  358. spc_error_struct.severity = XeError;
  359. spc_error_struct.use_errno = FALSE;
  360. break;
  361. case SPC_Inactive_Channel:
  362. spc_error_struct.format = (XeString) "><Channel is not active";
  363. spc_error_struct.severity = XeError;
  364. spc_error_struct.use_errno = FALSE;
  365. break;
  366. case SPC_Internal_Error:
  367. spc_error_struct.format = (XeString) "><Internal SPC Error";
  368. spc_error_struct.severity = XeError;
  369. spc_error_struct.use_errno = FALSE;
  370. break;
  371. case SPC_Cannot_Fork:
  372. spc_error_struct.format = (XeString) "><Cannot fork";
  373. spc_error_struct.severity = XeError;
  374. spc_error_struct.use_errno = TRUE;
  375. break;
  376. case SPC_Cannot_Exec:
  377. spc_error_struct.format = (XeString) "><Cannot exec file %s.\nPerhaps your PATH variable is incorrect.\nUse the following errno value to further diagnose the problem.";
  378. spc_error_struct.severity = XeError;
  379. spc_error_struct.use_errno = TRUE;
  380. break;
  381. case SPC_No_Pipe:
  382. spc_error_struct.format = (XeString) "><Cannot get pipe";
  383. spc_error_struct.severity = XeError;
  384. spc_error_struct.use_errno = TRUE;
  385. break;
  386. case SPC_No_Pty:
  387. spc_error_struct.format = (XeString) "><Unable to allocate pty for a DTSPCD channel.\nTry cleaning up some currently running processes to release their ptys,\nor reconfigure your kernel to increase the pty limit.";
  388. spc_error_struct.severity = XeError;
  389. spc_error_struct.use_errno = TRUE;
  390. break;
  391. case SPC_Bad_Connector:
  392. spc_error_struct.format = (XeString) "><Bad connector";
  393. spc_error_struct.severity = XeError;
  394. spc_error_struct.use_errno = FALSE;
  395. break;
  396. case SPC_Reading:
  397. spc_error_struct.format = (XeString) "><Unexpected error reading data on connection to host %s.\nUse the following errno value to correct the problem.";
  398. spc_error_struct.severity = XeError;
  399. spc_error_struct.use_errno = TRUE;
  400. break;
  401. case SPC_Writing:
  402. spc_error_struct.format = (XeString) "><Unexpected error writing data on channel";
  403. spc_error_struct.severity = XeError;
  404. spc_error_struct.use_errno = TRUE;
  405. break;
  406. case SPC_Bad_Service:
  407. spc_error_struct.format = (XeString) "><Unknown internet service %s/%s.\nMake an entry in your /etc/services file";
  408. spc_error_struct.severity = XeError;
  409. spc_error_struct.use_errno = TRUE;
  410. break;
  411. case SPC_Unknown_Host:
  412. spc_error_struct.format = (XeString) "><Unable to find a host entry for %s.\nTry adding an entry in /etc/hosts for it.";
  413. spc_error_struct.severity = XeError;
  414. spc_error_struct.use_errno = FALSE;
  415. break;
  416. case SPC_Bad_Socket:
  417. spc_error_struct.format = (XeString) "><Socket failed";
  418. spc_error_struct.severity = XeError;
  419. spc_error_struct.use_errno = TRUE;
  420. break;
  421. case SPC_Bad_Connect:
  422. spc_error_struct.format = (XeString) "><Connect call failed to remote host %s\nPerhaps the desktop is not installed on the remote host,\nor the remote inetd program needs to be restarted (via 'inetd -c'),\nor the remote file /etc/inetd.conf does not have an entry for the dtspcd process.\n";
  423. spc_error_struct.severity = XeError;
  424. spc_error_struct.use_errno = FALSE;
  425. break;
  426. case SPC_Bad_Bind:
  427. spc_error_struct.format = (XeString) "><Bind failed";
  428. spc_error_struct.severity = XeError;
  429. spc_error_struct.use_errno = TRUE;
  430. break;
  431. case SPC_Bad_Accept:
  432. spc_error_struct.format = (XeString) "><Accept failed";
  433. spc_error_struct.severity = XeError;
  434. spc_error_struct.use_errno = TRUE;
  435. break;
  436. case SPC_Bad_Reuse:
  437. spc_error_struct.format = (XeString) "><Reuse socket option failed";
  438. spc_error_struct.severity = XeError;
  439. spc_error_struct.use_errno = TRUE;
  440. break;
  441. case SPC_Bad_Open:
  442. spc_error_struct.format = (XeString) "><Cannot open file";
  443. spc_error_struct.severity = XeError;
  444. spc_error_struct.use_errno = TRUE;
  445. break;
  446. case SPC_Connection_EOF:
  447. if (SPC_who_am_i == SPC_I_AM_A_DAEMON)
  448. spc_error_struct.format = (XeString) "><Client has disconnected (received EOF).";
  449. else
  450. spc_error_struct.format = (XeString) "><The dtspcd process on host '%s' has terminated.";
  451. spc_error_struct.severity = XeError;
  452. spc_error_struct.use_errno = FALSE;
  453. break;
  454. case SPC_Timeout:
  455. spc_error_struct.format = (XeString) "><Internal timeout expired";
  456. spc_error_struct.severity = XeError;
  457. spc_error_struct.use_errno = FALSE;
  458. break;
  459. case SPC_Protocol:
  460. spc_error_struct.format = (XeString) "><Illegal protocol request";
  461. spc_error_struct.severity = XeError;
  462. spc_error_struct.use_errno = FALSE;
  463. break;
  464. case SPC_Unexpected_Reply:
  465. spc_error_struct.format = (XeString) "><Protocol error: unexpected reply";
  466. spc_error_struct.severity = XeError;
  467. spc_error_struct.use_errno = FALSE;
  468. break;
  469. case SPC_No_Channel:
  470. spc_error_struct.format = (XeString) "><Cannot initialize channel";
  471. spc_error_struct.severity = XeError;
  472. spc_error_struct.use_errno = FALSE;
  473. break;
  474. case SPC_Illegal_Iomode:
  475. spc_error_struct.format = (XeString) "><Inconsistent iomode value specified";
  476. spc_error_struct.severity = XeError;
  477. spc_error_struct.use_errno = FALSE;
  478. break;
  479. case SPC_No_Signal_Handler:
  480. spc_error_struct.format = (XeString) "><Cannot set SIGCLD handler";
  481. spc_error_struct.severity = XeError;
  482. spc_error_struct.use_errno = TRUE;
  483. break;
  484. case SPC_Bad_Operation:
  485. spc_error_struct.format = (XeString) "><Illegal operation";
  486. spc_error_struct.severity = XeError;
  487. spc_error_struct.use_errno = FALSE;
  488. break;
  489. case SPC_Bad_Fd:
  490. spc_error_struct.format = (XeString) "><Bad file descriptor";
  491. spc_error_struct.severity = XeError;
  492. spc_error_struct.use_errno = FALSE;
  493. break;
  494. case SPC_Bad_Ioctl:
  495. spc_error_struct.format = (XeString) "><ioctl call failed";
  496. spc_error_struct.severity = XeError;
  497. spc_error_struct.use_errno = TRUE;
  498. break;
  499. case SPC_Bad_Select:
  500. spc_error_struct.format = (XeString) "><select call failed";
  501. spc_error_struct.severity = XeError;
  502. spc_error_struct.use_errno = TRUE;
  503. break;
  504. case SPC_Bind_Timeout:
  505. spc_error_struct.format = (XeString) "><Timeout on bind";
  506. spc_error_struct.severity = XeWarning;
  507. spc_error_struct.use_errno = FALSE;
  508. break;
  509. case SPC_Arg_Too_Long:
  510. spc_error_struct.format = (XeString) "><Argument %.50s... to DTSPCD system call is too long, max. length is %d";
  511. spc_error_struct.severity = XeError;
  512. spc_error_struct.use_errno = FALSE;
  513. break;
  514. case SPC_Write_Prot:
  515. spc_error_struct.format = (XeString) "><Error writing protocol request to host %s.\nPerhaps the remote server has crashed.\nUse the following errno value to diagnose the problem.";
  516. spc_error_struct.severity = XeError;
  517. spc_error_struct.use_errno = TRUE;
  518. break;
  519. case SPC_Bad_Username:
  520. spc_error_struct.format = (XeString) "><Incorrect user name";
  521. spc_error_struct.severity = XeFatalError;
  522. spc_error_struct.use_errno = FALSE;
  523. break;
  524. case SPC_Bad_Password:
  525. spc_error_struct.format = (XeString) "><Incorrect password";
  526. spc_error_struct.severity = XeFatalError;
  527. spc_error_struct.use_errno = FALSE;
  528. break;
  529. case SPC_Client_Not_Valid:
  530. spc_error_struct.format = (XeString) "><Client not valid";
  531. spc_error_struct.severity = XeError;
  532. spc_error_struct.use_errno = FALSE;
  533. break;
  534. case SPC_Cannot_Open_Slave:
  535. spc_error_struct.format = (XeString) "><Unable to open slave pty %s.\nUse the following errno value to correct the problem";
  536. spc_error_struct.severity = XeError;
  537. spc_error_struct.use_errno = TRUE;
  538. break;
  539. case SPC_Protocol_Abort:
  540. spc_error_struct.format = (XeString) "><Received ABORT protocol request on connection to %s.";
  541. spc_error_struct.severity = XeFatalError;
  542. spc_error_struct.use_errno = FALSE;
  543. break;
  544. case SPC_Env_Too_Big:
  545. spc_error_struct.format = (XeString) "><Environment variable %.50s... too big,\nmaximum size is %d\n";
  546. spc_error_struct.severity = XeError;
  547. spc_error_struct.use_errno = FALSE;
  548. break;
  549. case SPC_Unlink_Logfile:
  550. spc_error_struct.format = (XeString) "><Cannot unlink logfile";
  551. spc_error_struct.severity = XeError;
  552. spc_error_struct.use_errno = TRUE;
  553. break;
  554. case SPC_Closed_Channel:
  555. spc_error_struct.format = (XeString) "><Channel already closed";
  556. spc_error_struct.severity = XeError;
  557. spc_error_struct.use_errno = FALSE;
  558. break;
  559. case SPC_Bad_Authentication:
  560. spc_error_struct.format = (XeString) "><Cannot open user authentication file";
  561. spc_error_struct.severity = XeFatalError;
  562. spc_error_struct.use_errno = FALSE;
  563. break;
  564. case SPC_Cannot_Open_Log:
  565. spc_error_struct.format = (XeString) "><Unable to open log file %s\nUse the following errno value to correct the problem";
  566. spc_error_struct.severity = XeError;
  567. spc_error_struct.use_errno = FALSE;
  568. break;
  569. case SPC_Connection_Reset:
  570. spc_error_struct.format = (XeString) "><Remote data connection to %s reset by peer\nRemote host may not have an entry for the local host in /usr/adm/inetd.sec.";
  571. spc_error_struct.severity = XeError;
  572. spc_error_struct.use_errno = FALSE;
  573. break;
  574. case SPC_Register_Username:
  575. spc_error_struct.format = (XeString) "><Cannot register user --\nImproper password or uid for user '%s' on remote host '%s'.";
  576. spc_error_struct.severity = XeError;
  577. spc_error_struct.use_errno = FALSE;
  578. break;
  579. case SPC_Register_Netrc:
  580. spc_error_struct.format = (XeString) "><Cannot register user --\nUnable to create a pathname to the authentication file '%s' on host '%s'.";
  581. spc_error_struct.severity = XeError;
  582. spc_error_struct.use_errno = FALSE;
  583. break;
  584. case SPC_Register_Open:
  585. spc_error_struct.format = (XeString) "><Cannot register user --\nUnable to open authentication file '%s' on host '%s'.\nUse the following errno value to diagnose the problem.";
  586. spc_error_struct.severity = XeError;
  587. spc_error_struct.use_errno = TRUE;
  588. break;
  589. case SPC_Register_Handshake:
  590. spc_error_struct.format = (XeString) "><Cannot register user --\nPerhaps user '%s' does not have the same uid on host '%s'.";
  591. spc_error_struct.severity = XeError;
  592. spc_error_struct.use_errno = FALSE;
  593. break;
  594. case SPC_Bad_Termios_Mode :
  595. spc_error_struct.format = (XeString) "><An error has been detected in the TERMIOS_REQUEST data.\nThe item '%s' is not recognized as a valid item for the Mode flags.\nThe item has been ignored.\n";
  596. spc_error_struct.severity = XeError;
  597. spc_error_struct.use_errno = FALSE;
  598. break;
  599. case SPC_Bad_Termios_Speed :
  600. spc_error_struct.format = (XeString) "><An error has been detected in the TERMIOS_REQUEST data.\nThe item '%s' is not recognized as a valid item for a speed setting.\nThe item has been ignored.\n";
  601. spc_error_struct.severity = XeError;
  602. spc_error_struct.use_errno = FALSE;
  603. break;
  604. case SPC_Bad_Termios_CC :
  605. spc_error_struct.format = (XeString) "><An error has been detected in the TERMIOS_REQUEST data.\nThe item '%s' is not recognized as a valid item for a Control Character name/value pair.\nThe item has been ignored.\n";
  606. spc_error_struct.severity = XeError;
  607. spc_error_struct.use_errno = FALSE;
  608. break;
  609. case SPC_Bad_Termios_Proto :
  610. spc_error_struct.format = (XeString) "><An error has been detected in the TERMIOS_REQUEST data.\nThe string does not have the correct number of fields -- %s.\n";
  611. spc_error_struct.severity = XeError;
  612. spc_error_struct.use_errno = FALSE;
  613. break;
  614. case SPC_Bad_Signal_Name :
  615. spc_error_struct.format = (XeString) "><The signal '%s' is not supported on this machine.\nThe DTSPCD signal request has been ignored.\n";
  616. spc_error_struct.severity = XeError;
  617. spc_error_struct.use_errno = FALSE;
  618. break;
  619. case SPC_Bad_Signal_Value :
  620. spc_error_struct.format = (XeString) "><The signal %d is not supported by the XeSignalToName() routine.\nIt can not be sent via DTSPCD to a remote machine.\n";
  621. spc_error_struct.severity = XeError;
  622. spc_error_struct.use_errno = FALSE;
  623. break;
  624. case SPC_Bad_Signal_Format :
  625. spc_error_struct.format = (XeString) "><The APPLICATION_SIGNAL DTSPCD data '%s' is not recognized.\nIt is expected to be a signal name or a signal number.\n";
  626. spc_error_struct.severity = XeError;
  627. spc_error_struct.use_errno = FALSE;
  628. break;
  629. case SPC_Bad_tc_Call :
  630. spc_error_struct.format = (XeString) "><The terminal control call to '%s' failed.";
  631. spc_error_struct.severity = XeError;
  632. spc_error_struct.use_errno = TRUE;
  633. break;
  634. case SPC_cannot_Chdir :
  635. spc_error_struct.format = (XeString) "><Cannot cd to directory '%s'.";
  636. spc_error_struct.severity = XeError;
  637. spc_error_struct.use_errno = TRUE;
  638. break;
  639. case SPC_Bad_Permission :
  640. spc_error_struct.format = (XeString) "><Incorrect permission on DTSPCD Authentication file.";
  641. spc_error_struct.severity = XeError;
  642. spc_error_struct.use_errno = TRUE;
  643. break;
  644. case SPC_Cannot_Create_Netfilename :
  645. spc_error_struct.format = (XeString) "><Cannot create a pathname to the current working\ndirectory '%s' from host '%s'.";
  646. spc_error_struct.severity = XeError;
  647. spc_error_struct.use_errno = FALSE;
  648. break;
  649. case SPC_Protocol_Version_Error:
  650. spc_error_struct.format = (XeString) "><SPC protocol version mismatch. The local version is %d, but the version of the SPC Daemon is %d. This operation requires equivalent protocol versions.";
  651. spc_error_struct.severity = XeError;
  652. spc_error_struct.use_errno = FALSE;
  653. break;
  654. /* JET - buffer overflow attempt */
  655. /* VU#172583 */
  656. case SPC_Buffer_Overflow:
  657. spc_error_struct.format = (XeString) "><Attempted Buffer Overflow from host %s.\nConnection dropped.";
  658. spc_error_struct.severity = XeError;
  659. spc_error_struct.use_errno = FALSE;
  660. break;
  661. default:
  662. spc_error_struct.format = (XeString) "><Unknown error code";
  663. spc_error_struct.severity = XeError;
  664. spc_error_struct.use_errno = FALSE;
  665. break;
  666. }
  667. _DtSvcProcessUnlock();
  668. return(&spc_error_struct);
  669. }