summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* New iface for getting plugins' infosZdenek Prikryl2009-07-316-23/+42
|
* updated urlZdenek Prikryl2009-07-311-1/+1
|
* added new option do bugzilla plugin.Zdenek Prikryl2009-07-314-18/+71
| | | | NoSSLVerify enables/disables certificate verification.
* rename auto variables to not have m_ prefixes - they are not members!Denys Vlasenko2009-07-311-19/+16
| | | | | | no logic changes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bug fixes in kerneloops scannerDenys Vlasenko2009-07-314-70/+60
| | | | | | | | | | | | | | | | | | | | | CKerneloopsScanner::Run - scan syslog file first, then dmesg (was other way around) CKerneloopsScanner::SaveOopsToDebug - cast time_t and size_t to long when we feed them to snprintf CKerneloopsScanner::ScanSysLogFile - do not seek to negative offsets, POSIX does not allow that CSysLog::QueueOops - plug memory leak Also used some abrtlib functions where appropriate, use open instead of fopen where appropriate, do not check error in time() - it never fails, move around bits of code in CKerneloopsScanner to make it easier in future to create a tool for parsing arbitrary files for oopses. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* using more x-functionsDenys Vlasenko2009-07-311-5/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* add utility functionsDenys Vlasenko2009-07-305-14/+441
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Logging machinery provided by this patch consists of several functions: +extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); +extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); +extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); +extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); +/* This is a macro since it collides with log() from math.h */ +#undef log +#define log(...) error_msg(__VA_ARGS__) They are taking printf-style format strings. perror_msg_xxx functions append an errno string after the message: "xxx xxx xxx: No such file or directory" if errno is != 0. xxx_and_die functions do not return. All functions also ensure that the message ends with "\n", meaning that you do not need to add it into the message, but if you do, an extra "\n" will not be added. All functions ensure that the string is written in a single write() call, thus if two processes output to the same terminal or file, messages don't get intermingled. Ordinarily, messages go to the stderr. By setting global variable "logmode" to LOGMODE_SYSLOG or LOGMODE_NONE, they can be sent to syslog or be suppressed. Standard setting is LOGMODE_STDIO. LOGMODE_STDIO + LOGMODE_SYSLOG works too. Usually it is set by main() as needed, and then you can fearlessly use [p]error_msg[_and_die]() and be sure that message goes to the right place. +enum { + LOGMODE_NONE = 0, + LOGMODE_STDIO = (1 << 0), + LOGMODE_SYSLOG = (1 << 1), + LOGMODE_BOTH = LOGMODE_SYSLOG + LOGMODE_STDIO, +}; +extern int logmode; Exit code of xxx_and_die variants is controlled by the global variable +extern int xfunc_error_retval; By default it is = 1. Logging infrastructure uses a few other functions, which I find useful on their own, and since I discussed them with Zdenek and he thinks that they may be useful too, they are included in the patch also. The first group is "malloc or die" group: +void* malloc_or_warn(size_t size); +void* xmalloc(size_t size); +void* xrealloc(void *ptr, size_t size); +void* xzalloc(size_t size); +char* xstrdup(const char *s); +char* xstrndup(const char *s, int n); They are basically versions of malloc etc which exit on failure. The next group are simple I/O wrappers: +extern ssize_t safe_read(int fd, void *buf, size_t count); +extern ssize_t full_read(int fd, void *buf, size_t count); +extern void xread(int fd, void *buf, size_t count); +extern ssize_t safe_write(int fd, const void *buf, size_t count); +extern ssize_t full_write(int fd, const void *buf, size_t count); safe_xxx deal with the fact that read and write operations may "fail" with EINTR and in many cases we want to just repeat the operation. full_xxx deal with the fact that read and write are not guaranteed to read or write exact amount, they may to transfer less bytes. In this case we need to loop. The next group are the "x functions": +extern void xwrite(int fd, const void *buf, size_t count); +extern void xwrite_str(int fd, const char *str); +void xpipe(int filedes[2]); +void xdup2(int from, int to); +off_t xlseek(int fd, off_t offset, int whence); +void xsetenv(const char *key, const char *value); +int xsocket(int domain, int type, int protocol); +void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen); +void xlisten(int s, int backlog); +ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, socklen_t tolen); +void xstat(const char *name, struct stat *stat_buf); +void xmove_fd(int from, int to); +char* xasprintf(const char *format, ...); They are similar to xmalloc in a sense that they exit on the failure. Most of them closely resemble corresponding libc functions. xmove_fd() is a wrapper for typical idiom "if (fd1!=fd2) dup2(fd1,fd2)", with error checking on dup2 failure added. xasprintf() is a "strcat on steroids". It's a printf-like function which returns a malloced string. In my experience, it is surprisingly useful: it makes complex concatenations easy in C. All these functions are declared in a new header, inc/abrtlib.h. It also contains a list of #includes: +#include <ctype.h> +#include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <inttypes.h> +#include <setjmp.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <stddef.h> +#include <string.h> +#include <sys/poll.h> +#include <sys/mman.h> +#include <sys/socket.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <termios.h> +#include <time.h> +#include <unistd.h> +/* Try to pull in PATH_MAX */ +#include <limits.h> +#include <sys/param.h> +#ifndef PATH_MAX +# define PATH_MAX 256 +#endif +#include <pwd.h> +#include <grp.h> The rationale to do so is that these headers are pretty standard, and by having them included in this one file, we won't need to add #includes into many .c[pp] files later. The slowdown from gcc parsing these headers even if they are not needed is not worth spending time on optimizing out. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* two trivial fixlets in lib/Plugins/CCpp.cppDenys Vlasenko2009-07-291-4/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* CommLayer: Added DaemonWatcher to watch if daemon is runningJiri Moskovcak2009-07-281-0/+88
|
* Be more paranoid about /proc/.../core_patternDenys Vlasenko2009-07-251-0/+17
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* fixed exception throwingZdenek Prikryl2009-07-241-2/+1
|
* Merge branch 'master' of git://git.fedorahosted.org/abrtZdenek Prikryl2009-07-244-55/+26
|\
| * remove superfluous copying in ExecVP paramsDenys Vlasenko2009-07-241-3/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * remove GetGIDFromUID (two copies): getpwuid does the sameDenys Vlasenko2009-07-244-47/+12
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * simplify CAnalyzerCCpp::CreateHashDenys Vlasenko2009-07-241-5/+12
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | plugin can report to different bugzillas in different reportsZdenek Prikryl2009-07-241-9/+18
| |
* | proper deinit of libmagicZdenek Prikryl2009-07-241-2/+2
| |
* | simple fixZdenek Prikryl2009-07-241-1/+1
| |
* | Added first part of gui support in reportingZdenek Prikryl2009-07-2422-23/+90
| |
* | Added gui desriptions for reportersZdenek Prikryl2009-07-244-0/+574
|/
* style fix by popular (Zdenek's) demandDenys Vlasenko2009-07-231-6/+3
| | | | | | | | | | | | | | | Zdenek said: Ahother thing: commit "CCpp.cpp: fix handling of pipes when we fork children". You added piece code with while(1) and then there is a break inside the loop. Personally, I don't like infinite loops :-). There can be something like: ... int r; while ((r = read(pipeout[0], buff, sizeof(buff) - 1) > 0) { Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* typo fixesDenys Vlasenko2009-07-232-29/+28
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* added forgotten "throw" keywordsDenys Vlasenko2009-07-221-3/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* CCpp.cpp: fix handling of pipes when we fork childrenDenys Vlasenko2009-07-221-122/+137
| | | | | | Also simplified read loops Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Merge branch 'master' of ssh://git.fedorahosted.org/git/abrtJiri Moskovcak2009-07-221-15/+19
|\
| * fix several resource leaks on error pathsDenys Vlasenko2009-07-221-15/+19
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Utils: small fixJiri Moskovcak2009-07-221-1/+1
| |
* | CommLayer: added new signal "Warning"Jiri Moskovcak2009-07-222-0/+9
|/
* Fix build system for the case where configure was run with non-default prefixDenys Vlasenko2009-07-203-4/+9
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Merge branch 'master' of ssh://git.fedorahosted.org/git/abrtJiri Moskovcak2009-07-201-1/+1
|\
| * Restore /proc/sys/kernel/core_pattern on error exit.Denys Vlasenko2009-07-151-1/+1
| | | | | | | | | | | | The bug was observed when dbus-abrt.conf is missing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | CCpp: Made it more verboseJiri Moskovcak2009-07-201-2/+3
| |
* | Daemon: added threaded CreateReport -> breaks CLI!Jiri Moskovcak2009-07-205-5/+79
|/
* Use CABRTException instead of throwing std::stringJiri Moskovcak2009-07-071-1/+2
|
* Added dbus client to commlayerJiri Moskovcak2009-07-076-9/+78
|
* documentation after English language review from rlandman@redhat.comDaniel Novotny2009-07-039-76/+77
|
* fixed security issueZdenek Prikryl2009-06-308-30/+87
| | | | User can read only his debugdump directories
* Added new SOSreport plugin.Zdenek Prikryl2009-06-291-0/+5
|
* New SOSreport plugin. Written by Gavin Romig-Koch (gavin@redhat.com)Zdenek Prikryl2009-06-292-0/+165
|
* added commentsZdenek Prikryl2009-06-2911-64/+566
|
* fixed getting list of errors for rootZdenek Prikryl2009-06-291-5/+5
|
* there is no nees to init nss because of creating hashZdenek Prikryl2009-06-241-7/+2
|
* minor fixesZdenek Prikryl2009-06-242-1/+5
|
* security issuesZdenek Prikryl2009-06-231-5/+9
|
* Handle logs with NUL chars betterMichal Schmidt2009-06-203-42/+39
| | | | | | | | | | | It is not too rare that '\0' chars appear in /var/log/messages. I saw a real-life case where kerneloops would show a popup with the same old oops after every login. It turned out that there were NUL chars in the log which prevented kerneloops from seeing its marker, so it always treated the old oops in the log as new. This patch fixes it by always going through the whole known length of the buffer (not stopping on NUL chars) and using less string-oriented functions in fill_lineinfo().
* Use less memoryAnton Arapov2009-06-202-62/+79
| | | | | | | | | | | | * backport of 14e769d7093179943015ff88d0d3bdd65b2947f7 * Author: Michal Schmidt <mschmidt@redhat.com> The linepointer array is huge!: linepointer = calloc(buflen+1, sizeof(char*)); buflen can be as much as 32 MB, that makes it allocate 32M*8 = 256M on x86_64. Fix it by growing the allocation dynamically as we find interesting lines in the log.
* Really limit max size of log to read to 32 MBMichal Schmidt2009-06-201-3/+3
| | | | | Because of MAX/MIN confusion, the buffer size was always at least 32 MB, instead of at most 32 MB as intended.
* new default socket pathZdenek Prikryl2009-06-173-5/+6
|
* added man pages to Makefile.amDaniel Novotny2009-06-161-1/+4
|
* new manual pagesDaniel Novotny2009-06-169-4/+358
|