summaryrefslogtreecommitdiffstats
path: root/inc/abrtlib.h
Commit message (Collapse)AuthorAgeFilesLines
* Move backtrace parser from src/Backtrace to lib/Utils.Karel Klic2010-03-261-49/+1
| | | | | | | | | | | | | | | Move abrt-backtrace app from src/Backtrace/main.c to src/utils/abrt-backtrace. Move backtrace preprocessign code from abrt-backtrace to the parser. Implemented new backtrace rating algorithm. Added old bt rating algorithm to backtrace.c Move strbuf to lib/Utils, and updated it to use xfuncs. Created separate header for xfuncs. Some functions in xfuncs marked as extern "c", so they can be used in C code. Merged backtrace fallback (independent_backtrace) "parser" into backtrace.{h/c}. Added option --rate to abrt-backtrace, to be able to use the new backtrace rating algorithm in scripts.
* abrt-hook-ccpp: do not consider SIGQUIT to be a crashDenys Vlasenko2010-02-121-0/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* get_home_dir uses uid_t for the uidKarel Klic2010-02-121-1/+1
|
* Added comment to perror_msg declaration.Karel Klic2010-02-121-0/+1
|
* make "reason" field less verbose; bz reporter: include it in "summary"Denys Vlasenko2010-02-081-0/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* fix my goof in to_string()Denys Vlasenko2010-02-081-4/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: remove all usages of C++ streams (-10k in code size)Denys Vlasenko2010-02-071-7/+6
| | | | | | Also add copyright banners to all files which were missing them Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* remove unused getuidbynameDenys Vlasenko2010-01-221-1/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: assorted fixes prompted by security analysis; more to comeDenys Vlasenko2010-01-111-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* SOSreport/TicketUploader: use more restrictive file modesDenys Vlasenko2010-01-111-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* RunApp: safer chdir. Overhauled "sparn a child and get its output" in generalDenys Vlasenko2010-01-111-1/+25
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* moved get_cmdline() and daemon_is_ok() to abrtlibKarel Klic2009-12-181-0/+10
|
* fix all instances of atoi() usageDenys Vlasenko2009-12-151-0/+9
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* add paranoia checks on setuid/setgidDenys Vlasenko2009-12-141-0/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* remove one case when we write data needlessly; remove 2 unused funcsDenys Vlasenko2009-12-101-2/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* SQLite3: string& -> char*, -8k in code sizeDenys Vlasenko2009-12-031-0/+1
| | | | | | Run tested Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* fixes on top of AutoReportUIDs change. run testedDenys Vlasenko2009-11-301-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* a few fixes in automatic reporterNikola Pajkovsky2009-11-301-1/+1
|
* Kerneloops are reported automaticky now when AutoReportUIDs = root is in ↵Nikola Pajkovsky2009-11-261-0/+1
| | | | | | Kerneloops.conf Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
* hookCCpp: check total dump dir size and delete the largest/oldest oneDenys Vlasenko2009-11-261-0/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* SOSreport.cpp: __gnu_cxx::stdio_filebuf<char> is +8k in code, thanks but noDenys Vlasenko2009-11-121-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Factored ParseArgNikola Pajkovsky2009-11-121-0/+3
|
* remove getSettings from most plugins (inherited one is ok)Denys Vlasenko2009-11-101-0/+2
| | | | | | | | | Also move parse_release() to abrtlib, it's shared among Bugzilla and Catcut. Tested Bugzilla and Catcut, both work. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* simplify logging a bit. warn_client() is gone, reuse error_msg() for it.Denys Vlasenko2009-11-061-19/+17
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* make exception handling lighterDenys Vlasenko2009-11-061-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* lib/Plugins/FileTransfer: massive surgeryDenys Vlasenko2009-11-061-0/+2
| | | | | | | | text data bss dec hex filename 50212 2144 16 52372 cc94 0/libTicketUploader.so 34693 1888 24 36605 8efd 1/libTicketUploader.so Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* InformAllUsers support. enabled by default for Kerneloops. Tested wuth CCpp.Denys Vlasenko2009-11-051-0/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* lib/Plugins/CCpp: respect DebugInfoCacheMB settingDenys Vlasenko2009-11-021-0/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* simplify base64 conversionDenys Vlasenko2009-10-271-0/+4
| | | | | | | | text data bss dec hexfilename 39575 2016 288 41879 old/libBugzilla.so 38598 1840 288 40726 new/libBugzilla.so Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* add bits of infrastructure needed for xmlprc code.Denys Vlasenko2009-10-261-0/+51
| | | | | | This does not affect existing code in any way. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* fix all instances of dent->d_type == DT_REG checksDenys Vlasenko2009-09-301-0/+7
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* factored out dbus init from CommLayerServerDBus.cpp to lib/Utils/abrt_dbus.cppDenys Vlasenko2009-09-171-0/+11
| | | | | | this will allow me to reuse this code for applet Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* eliminate CDebugDump::m_bUnlock, m_nLockfileFD can be used insteadDenys Vlasenko2009-09-091-0/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* move die_out_of_memory() to abrtlibDenys Vlasenko2009-09-011-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* replace comm_layer_inner_debug() with log() everywhereDenys Vlasenko2009-08-261-1/+7
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* move to_string() helper to abrtlib.hDenys Vlasenko2009-08-251-1/+14
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* move most of CCrashWatcher's init/deinit into daemon's main()Denys Vlasenko2009-08-211-0/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* new function for gettings user's home directoryZdenek Prikryl2009-08-111-0/+2
|
* fix compile-time warnings.Denys Vlasenko2009-08-091-0/+1
| | | | | | | One fix (in CCrashWatcher::GetPluginsInfo) needs closer look, others are "trivially correct" Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Hooks/CCpp.cpp: don't dump executables with "/abrt" substring in the nameDenys Vlasenko2009-08-051-0/+3
| | | | | | some cleanups and abrtlib work crept in too... Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* simplify C/C++ hookDenys Vlasenko2009-08-051-0/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* KerneloopsReporter: plug a leak in writefunctionDenys Vlasenko2009-07-311-0/+5
| | | | | | Also some preparatory cleanups for future dumpoops patch are included Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* add utility functionsDenys Vlasenko2009-07-301-0/+102
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>