Linux ip-172-26-2-223 5.4.0-1018-aws #18-Ubuntu SMP Wed Jun 24 01:15:00 UTC 2020 x86_64
Apache
: 172.26.2.223 | : 52.14.184.10
Cant Read [ /etc/named.conf ]
8.1.13
www
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
usr /
share /
doc /
comerr-dev /
html-info /
[ HOME SHELL ]
Name
Size
Permission
Action
com_err.html
26.01
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : com_err.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>A Common Error Description Library for UNIX</title> <meta name="description" content="A Common Error Description Library for UNIX"> <meta name="keywords" content="A Common Error Description Library for UNIX"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> <link href="#Top" rel="start" title="Top"> <link href="#SEC_Contents" rel="contents" title="Table of Contents"> <link href="dir.html#Top" rel="up" title="(dir)"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} blockquote.indentedblock {margin-right: 0em} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} div.lisp {margin-left: 3.2em} kbd {font-style: oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} span.nolinebreak {white-space: nowrap} span.roman {font-family: initial; font-weight: normal} span.sansserif {font-family: sans-serif; font-weight: normal} ul.no-bullet {list-style: none} --> </style> </head> <body lang="en"> <h1 class="settitle" align="center">A Common Error Description Library for UNIX</h1> <span id="Top"></span><div class="header"> <p> Next: <a href="#Why-com_005ferr_003f" accesskey="n" rel="next">Why com_err?</a>, Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href="dir.html#Top" accesskey="u" rel="up">(dir)</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> </div> <span id="A-Common-Error-Description-Library-for-UNIX"></span><h1 class="top">A Common Error Description Library for UNIX</h1> <p>This manual documents the com_err library. </p> <table class="menu" border="0" cellspacing="0"> <tr><td align="left" valign="top">• <a href="#Why-com_005ferr_003f" accesskey="1">Why com_err?</a></td><td> </td><td align="left" valign="top"> </td></tr> <tr><td align="left" valign="top">• <a href="#Error-codes" accesskey="2">Error codes</a></td><td> </td><td align="left" valign="top"> </td></tr> <tr><td align="left" valign="top">• <a href="#Error-table-source-file" accesskey="3">Error table source file</a></td><td> </td><td align="left" valign="top"> </td></tr> <tr><td align="left" valign="top">• <a href="#The-error_002dtable-compiler" accesskey="4">The error-table compiler</a></td><td> </td><td align="left" valign="top"> </td></tr> <tr><td align="left" valign="top">• <a href="#Run_002dtime-support-routines" accesskey="5">Run-time support routines</a></td><td> </td><td align="left" valign="top"> </td></tr> <tr><td align="left" valign="top">• <a href="#Coding-Conventions" accesskey="6">Coding Conventions</a></td><td> </td><td align="left" valign="top"> </td></tr> <tr><td align="left" valign="top">• <a href="#Building-and-Installation" accesskey="7">Building and Installation</a></td><td> </td><td align="left" valign="top"> </td></tr> <tr><td align="left" valign="top">• <a href="#Bug-Reports" accesskey="8">Bug Reports</a></td><td> </td><td align="left" valign="top"> </td></tr> <tr><td align="left" valign="top">• <a href="#Acknowledgements" accesskey="9">Acknowledgements</a></td><td> </td><td align="left" valign="top"> </td></tr> </table> <hr> <span id="Why-com_005ferr_003f"></span><div class="header"> <p> Next: <a href="#Error-codes" accesskey="n" rel="next">Error codes</a>, Previous: <a href="#Top" accesskey="p" rel="prev">Top</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> </div> <span id="Why-com_005ferr_003f-1"></span><h2 class="chapter">1 Why com_err?</h2> <p>In building application software packages, a programmer often has to deal with a number of libraries, each of which can use a different error-reporting mechanism. Sometimes one of two values is returned, indicating simply SUCCESS or FAILURE, with no description of errors encountered. Sometimes it is an index into a table of text strings, where the name of the table used is dependent on the library being used when the error is generated; since each table starts numbering at 0 or 1, additional information as to the source of the error code is needed to determine which table to look at. Sometimes no text messages are supplied at all, and the programmer must supply them at any point at which he may wish to report error conditions. Often, a global variable is assigned some value describing the error, but the programmer has to know in each case whether to look at <code>errno</code>, <code>h_errno</code>, the return value from <code>hes_err()</code>, or whatever other variables or routines are specified. And what happens if something in the procedure of examining or reporting the error changes the same variable? </p> <p>The package we have developed is an attempt to present a common error-handling mechanism to manipulate the most common form of error code in a fashion that does not have the problems listed above. </p> <p>A list of up to 256 text messages is supplied to a translator we have written, along with the three- to four-character “name” of the error table. The library using this error table need only call a routine generated from this error-table source to make the table “known” to the com_err library, and any error code the library generates can be converted to the corresponding error message. There is also a default format for error codes accidentally returned before making the table known, which is of the form ‘<samp>unknown code foo 32</samp>’, where ‘<samp>foo</samp>’ would be the name of the table. </p> <hr> <span id="Error-codes"></span><div class="header"> <p> Next: <a href="#Error-table-source-file" accesskey="n" rel="next">Error table source file</a>, Previous: <a href="#Why-com_005ferr_003f" accesskey="p" rel="prev">Why com_err?</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> </div> <span id="Error-codes-1"></span><h2 class="chapter">2 Error codes</h2> <p>Error codes themselves are 32 bit (signed) integers, of which the high order 24 bits are an identifier of which error table the error code is from, and the low order 8 bits are a sequential error number within the table. An error code may thus be easily decomposed into its component parts. Only the lowest 32 bits of an error code are considered significant on systems which support wider values. </p> <p>Error table 0 is defined to match the UNIX system call error table (<code>sys_errlist</code>); this allows <code>errno</code> values to be used directly in the library (assuming that <code>errno</code> is of a type with the same width as <tt>long</tt>). Other error table numbers are formed by compacting together the first four characters of the error table name. The mapping between characters in the name and numeric values in the error code are defined in a system-independent fashion, so that two systems that can pass integral values between them can reliably pass error codes without loss of meaning; this should work even if the character sets used are not the same. (However, if this is to be done, error table 0 should be avoided, since the local system call error tables may differ.) </p> <p>Any variable which is to contain an error code should be declared <tt>long</tt>. The draft proposed American National Standard for C (as of May, 1988) requires that <tt>long</tt> variables be at least 32 bits; any system which does not support 32-bit <tt>long</tt> values cannot make use of this package (nor much other software that assumes an ANSI-C environment base) without significant effort. </p> <hr> <span id="Error-table-source-file"></span><div class="header"> <p> Next: <a href="#The-error_002dtable-compiler" accesskey="n" rel="next">The error-table compiler</a>, Previous: <a href="#Error-codes" accesskey="p" rel="prev">Error codes</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> </div> <span id="Error-table-source-file-1"></span><h2 class="chapter">3 Error table source file</h2> <p>The error table source file begins with the declaration of the table name, as </p> <div class="example"> <pre class="example">error_table <var>tablename</var> </pre></div> <p>Individual error codes are specified with </p> <div class="example"> <pre class="example">error_code <var>ERROR_NAME</var>, <var>"text message"</var> </pre></div> <p>where ‘<samp>ec</samp>’ can also be used as a short form of ‘<samp>error_code</samp>’. To indicate the end of the table, use ‘<samp>end</samp>’. Thus, a (short) sample error table might be: </p> <div class="example"> <pre class="example"> error_table dsc error_code DSC_DUP_MTG_NAME, "Meeting already exists" ec DSC_BAD_PATH, "A bad meeting pathname was given" ec DSC_BAD_MODES, "Invalid mode for this access control list" end </pre></div> <hr> <span id="The-error_002dtable-compiler"></span><div class="header"> <p> Next: <a href="#Run_002dtime-support-routines" accesskey="n" rel="next">Run-time support routines</a>, Previous: <a href="#Error-table-source-file" accesskey="p" rel="prev">Error table source file</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> </div> <span id="The-error_002dtable-compiler-1"></span><h2 class="chapter">4 The error-table compiler</h2> <p>The error table compiler is named <code>compile_et</code>. It takes one argument, the pathname of a file (ending in ‘<samp>.et</samp>’, e.g., ‘<samp>dsc_err.et</samp>’) containing an error table source file. It parses the error table, and generates two output files – a C header file (‘<samp>discuss_err.h</samp>’) which contains definitions of the numerical values of the error codes defined in the error table, and a C source file which should be compiled and linked with the executable. The header file must be included in the source of a module which wishes to reference the error codes defined; the object module generated from the C code may be linked in to a program which wishes to use the printed forms of the error codes. </p> <hr> <span id="Run_002dtime-support-routines"></span><div class="header"> <p> Next: <a href="#Coding-Conventions" accesskey="n" rel="next">Coding Conventions</a>, Previous: <a href="#The-error_002dtable-compiler" accesskey="p" rel="prev">The error-table compiler</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> </div> <span id="Run_002dtime-support-routines-1"></span><h2 class="chapter">5 Run-time support routines</h2> <p>Any source file which uses the routines supplied with or produced by the com_err package should include the header file <samp><com_err.h></samp>. It contains declarations and definitions which may be needed on some systems. (Some functions cannot be referenced properly without the return type declarations in this file. Some functions may work properly on most architectures even without the header file, but relying on this is not recommended.) </p> <p>The run-time support routines and variables provided via this package include the following: </p> <div class="example"> <pre class="example">void initialize_<var>xxxx</var>_error_table (void); </pre></div> <p>One of these routines is built by the error compiler for each error table. It makes the <var>xxxx</var> error table “known” to the error reporting system. By convention, this routine should be called in the initialization routine of the <var>xxxx</var> library. If the library has no initialization routine, some combination of routines which form the core of the library should ensure that this routine is called. It is not advised to leave it the caller to make this call. </p> <p>There is no harm in calling this routine more than once. </p> <div class="example"> <pre class="example">#define ERROR_TABLE_BASE_<var>xxxx</var> <var>nnnnn</var>L </pre></div> <p>This symbol contains the value of the first error code entry in the specified table. This rarely needs be used by the programmer. </p> <dl> <dt id="index-char">Function: <em>const</em> <strong>char</strong> <em>*error_message (long <var>code</var>);</em></dt> <dd> <p>This routine returns the character string error message associated with <code>code</code>; if this is associated with an unknown error table, or if the code is associated with a known error table but the code is not in the table, a string of the form ‘<samp>Unknown code <var>xxxx nn</var></samp>’ is returned, where <var>xxxx</var> is the error table name produced by reversing the compaction performed on the error table number implied by that error code, and <var>nn</var> is the offset from that base value. </p> <p>Although this routine is available for use when needed, its use should be left to circumstances which render <code>com_err</code> (below) unusable. </p> </dd></dl> <dl> <dt id="index-com_005ferr">Function: <em>void</em> <strong>com_err</strong> <em>(const char *<var>whoami</var>, long <var>error_code</var>, const char *<var>format</var>, ...);</em></dt> <dd> <p>This routine provides an alternate way to print error messages to standard error; it allows the error message to be passed in as a parameter, rather than in an external variable. <em>Provide grammatical context for “message.”</em> </p> <p>The module reporting the error should be passed in via <var>whoami</var>. If <var>format</var> is <code>(char *)NULL</code>, the formatted message will not be printed. <var>format</var> may not be omitted. </p> </dd></dl> <dl> <dt id="index-com_005ferr_005fva">Function: <em>void</em> <strong>com_err_va</strong> <em>(const char *<var>whoami</var>, long <var>error_code</var>, const char *<var>format</var>, va_list <var>args</var>);</em></dt> <dd> <p>This routine provides an interface, equivalent to <code>com_err</code> above, which may be used by higher-level variadic functions (functions which accept variable numbers of arguments). </p> </dd></dl> <dl> <dt id="index-_002aset_005fcom_005ferr_005fhook">Function: <em>void</em> <strong>*set_com_err_hook</strong> <em>(void (*<var>proc</var>) (const char *<var>whoami</var>, long <var>error_code</var>, va_list <var>args</var>) (const char *<var>whoami</var>, long <var>error_code</var>, va_list <var>args</var>));</em></dt> <dt id="index-reset_005fcom_005ferr_005fhook">Function: <em>void</em> <strong>reset_com_err_hook</strong> <em>();</em></dt> <dd> <p>These two routines allow a routine to be dynamically substituted for ‘<samp>com_err</samp>’. After ‘<samp>set_com_err_hook</samp>’ has been called, calls to ‘<samp>com_err</samp>’ will turn into calls to the new hook routine. ‘<samp>reset_com_err_hook</samp>’ turns off this hook. This may intended to be used in daemons (to use a routine which calls <cite>syslog(3)</cite>), or in a window system application (which could pop up a dialogue box). </p> <p>If a program is to be used in an environment in which simply printing messages to the <code>stderr</code> stream would be inappropriate (such as in a daemon program which runs without a terminal attached), <code>set_com_err_hook</code> may be used to redirect output from <code>com_err</code>. The following is an example of an error handler which uses <cite>syslog(3)</cite> as supplied in BSD 4.3: </p> <div class="example"> <pre class="example">#include <stdio.h> #include <stdarg.h> #include <syslog.h> /* extern openlog (const char * name, int logopt, int facility); */ /* extern syslog (int priority, char * message, ...); */ void hook (const char * whoami, long code, const char * format, va_list args) { char buffer[BUFSIZ]; static int initialized = 0; if (!initialized) { openlog (whoami, LOG_NOWAIT|LOG_CONS|LOG_PID|LOG_NDELAY, LOG_DAEMON); initialized = 1; } vsprintf (buffer, format, args); syslog (LOG_ERR, "%s %s", error_message (code), buffer); } </pre></div> <p>After making the call <code>set_com_err_hook (hook);</code>, any calls to <code>com_err</code> will result in messages being sent to the <var>syslogd</var> daemon for logging. The name of the program, ‘<samp>whoami</samp>’, is supplied to the ‘<samp>openlog()</samp>’ call, and the message is formatted into a buffer and passed to <code>syslog</code>. </p> <p>Note that since the extra arguments to <code>com_err</code> are passed by reference via the <code>va_list</code> value <code>args</code>, the hook routine may place any form of interpretation on them, including ignoring them. For consistency, <code>printf</code>-style interpretation is suggested, via <code>vsprintf</code> (or <code>_doprnt</code> on BSD systems without full support for the ANSI C library). </p> </dd></dl> <hr> <span id="Coding-Conventions"></span><div class="header"> <p> Next: <a href="#Building-and-Installation" accesskey="n" rel="next">Building and Installation</a>, Previous: <a href="#Run_002dtime-support-routines" accesskey="p" rel="prev">Run-time support routines</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> </div> <span id="Coding-Conventions-1"></span><h2 class="chapter">6 Coding Conventions</h2> <p>The following conventions are just some general stylistic conventions to follow when writing robust libraries and programs. Conventions similar to this are generally followed inside the UNIX kernel and most routines in the Multics operating system. In general, a routine either succeeds (returning a zero error code, and doing some side effects in the process), or it fails, doing minimal side effects; in any event, any invariant which the library assumes must be maintained. </p> <p>In general, it is not in the domain of non user-interface library routines to write error messages to the user’s terminal, or halt the process. Such forms of “error handling” should be reserved for failures of internal invariants and consistency checks only, as it provides the user of the library no way to clean up for himself in the event of total failure. </p> <p>Library routines which can fail should be set up to return an error code. This should usually be done as the return value of the function; if this is not acceptable, the routine should return a “null” value, and put the error code into a parameter passed by reference. </p> <p>Routines which use the first style of interface can be used from user-interface levels of a program as follows: </p> <div class="example"> <pre class="example">{ if ((code = initialize_world(getuid(), random())) != 0) { com_err("demo", code, "when trying to initialize world"); exit(1); } if ((database = open_database("my_secrets", &code))==NULL) { com_err("demo", code, "while opening my_secrets"); exit(1); } } </pre></div> <p>A caller which fails to check the return status is in error. It is possible to look for code which ignores error returns by using lint; look for error messages of the form “foobar returns value which is sometimes ignored” or “foobar returns value which is always ignored.” </p> <p>Since libraries may be built out of other libraries, it is often necessary for the success of one routine to depend on another. When a lower level routine returns an error code, the middle level routine has a few possible options. It can simply return the error code to its caller after doing some form of cleanup, it can substitute one of its own, or it can take corrective action of its own and continue normally. For instance, a library routine which makes a “connect” system call to make a network connection may reflect the system error code <code>ECONNREFUSED</code> (Connection refused) to its caller, or it may return a “server not available, try again later,” or it may try a different server. </p> <p>Cleanup which is typically necessary may include, but not be limited to, freeing allocated memory which will not be needed any more, unlocking concurrency locks, dropping reference counts, closing file descriptors, or otherwise undoing anything which the procedure did up to this point. When there are a lot of things which can go wrong, it is generally good to write one block of error-handling code which is branched to, using a goto, in the event of failure. A common source of errors in UNIX programs is failing to close file descriptors on error returns; this leaves a number of “zombied” file descriptors open, which eventually causes the process to run out of file descriptors and fall over. </p> <div class="example"> <pre class="example">{ FILE *f1=NULL, *f2=NULL, *f3=NULL; int status = 0; if ( (f1 = fopen(FILE1, "r")) == NULL) { status = errno; goto error; } /* * Crunch for a while */ if ( (f2 = fopen(FILE2, "w")) == NULL) { status = errno; goto error; } if ( (f3 = fopen(FILE3, "a+")) == NULL) { status = errno; goto error; } /* * Do more processing. */ fclose(f1); fclose(f2); fclose(f3); return 0; error: if (f1) fclose(f1); if (f2) fclose(f2); if (f3) fclose(f3); return status; } </pre></div> <hr> <span id="Building-and-Installation"></span><div class="header"> <p> Next: <a href="#Bug-Reports" accesskey="n" rel="next">Bug Reports</a>, Previous: <a href="#Coding-Conventions" accesskey="p" rel="prev">Coding Conventions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> </div> <span id="Building-and-Installation-1"></span><h2 class="chapter">7 Building and Installation</h2> <p>The distribution of this package will probably be done as a compressed “tar”-format file available via anonymous FTP from SIPB.MIT.EDU. Retrieve ‘<samp>pub/com_err.tar.Z</samp>’ and extract the contents. A subdirectory <tt>profiled</tt> should be created to hold objects compiled for profiling. Running “make all” should then be sufficient to build the library and error-table compiler. The files ‘<samp>libcom_err.a</samp>’, ‘<samp>libcom_err_p.a</samp>’, ‘<samp>com_err.h</samp>’, and ‘<samp>compile_et</samp>’ should be installed for use; ‘<samp>com_err.3</samp>’ and ‘<samp>compile_et.1</samp>’ can also be installed as manual pages. </p> <hr> <span id="Bug-Reports"></span><div class="header"> <p> Next: <a href="#Acknowledgements" accesskey="n" rel="next">Acknowledgements</a>, Previous: <a href="#Building-and-Installation" accesskey="p" rel="prev">Building and Installation</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> </div> <span id="Bug-Reports-1"></span><h2 class="chapter">8 Bug Reports</h2> <p>The principal author of this library is: Ken Raeburn, <tt>raeburn@MIT.EDU</tt>. </p> <p>This version of the com_err library is being maintained by Theodore Ts’o, and so bugs and comments should be sent to <tt>tytso@thunk.org</tt>. </p> <hr> <span id="Acknowledgements"></span><div class="header"> <p> Previous: <a href="#Bug-Reports" accesskey="p" rel="prev">Bug Reports</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> </div> <span id="Acknowledgements-1"></span><h2 class="chapter">9 Acknowledgements</h2> <p>I would like to thank: Bill Sommerfeld, for his help with some of this documentation, and catching some of the bugs the first time around; Honeywell Information Systems, for not killing off the <em>Multics</em> operating system before I had an opportunity to use it; Honeywell’s customers, who persuaded them not to do so, for a while; Ted Anderson of CMU, for catching some problems before version 1.2 left the nest; Stan Zanarotti and several others of MIT’s Student Information Processing Board, for getting us started with “discuss,” for which this package was originally written; and everyone I’ve talked into — I mean, asked to read this document and the “man” pages. </p> <span id="SEC_Contents"></span> <h2 class="contents-heading">Table of Contents</h2> <div class="contents"> <ul class="no-bullet"> <li><a id="toc-Why-com_005ferr_003f-1" href="#Why-com_005ferr_003f">1 Why com_err?</a></li> <li><a id="toc-Error-codes-1" href="#Error-codes">2 Error codes</a></li> <li><a id="toc-Error-table-source-file-1" href="#Error-table-source-file">3 Error table source file</a></li> <li><a id="toc-The-error_002dtable-compiler-1" href="#The-error_002dtable-compiler">4 The error-table compiler</a></li> <li><a id="toc-Run_002dtime-support-routines-1" href="#Run_002dtime-support-routines">5 Run-time support routines</a></li> <li><a id="toc-Coding-Conventions-1" href="#Coding-Conventions">6 Coding Conventions</a></li> <li><a id="toc-Building-and-Installation-1" href="#Building-and-Installation">7 Building and Installation</a></li> <li><a id="toc-Bug-Reports-1" href="#Bug-Reports">8 Bug Reports</a></li> <li><a id="toc-Acknowledgements-1" href="#Acknowledgements">9 Acknowledgements</a></li> </ul> </div> <hr> </body> </html>
Close