Mercurial > noffle
view src/dynamicstring.c @ 288:c02c4eb95f95 noffle
[svn] * src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
and noffle-group configs.
* src/configfile.c,src/fetch.c,src/fetchlist.c,src/protocol.c,
src/server.c: Replace strcpy() with Utl_cpyStr() where appropriate.
See Debian bug 168128.
* src/control.c,src/configfile.c,src/noffle.c: Replace [s]scanf("%s")
with [s]scanf(MAXCHAR_FMT).
* src/noffle.c: Log warning if noffle.conf is world readable.
* src/noffle.c: Restrict most options to news admins; i.e. those who
are root or news on running Noffle.
* Makefile.in,acconfig.h,aclocal.m4,config.h.in,configure,configure.in,
docs/Makefile.in,docs/noffle.conf.5,packages/Makefile.in,
packages/redhat/Makefile.in,src/Makefile.am,src/Makefile.in,
src/authenticate.c,src/authenticate.h,src/noffle.c,src/server.c:
Add basic authentication using either Noffle-specific user file
or authenticating via PAM (service 'noffle'). PAM authentication
needs to run as root, so a Noffle server that needs PAM
must be started by root. Helpful (?) error messages will be logged
if not. Noffle will switch ruid and euid to 'news' (or whatever
is configured) ASAP.
* src/noffle.c: Add uid checking.
author | bears |
---|---|
date | Fri, 10 Jan 2003 23:25:45 +0000 |
parents | 5eece4dfd945 |
children |
line wrap: on
line source
/* dynamicstring.c $Id: dynamicstring.c 413 2002-12-27 21:48:25Z bears $ */ #if HAVE_CONFIG_H #include <config.h> #endif #include <sys/types.h> #include "dynamicstring.h" #include "log.h" #include "portable.h" struct DynStr { int len; /* Current length (without trailing '\0') */ int max; /* Max length that fits into buffer (incl. trailing '\0') */ char *str; }; static void reallocStr( DynStr *self, int max ) { ASSERT( max >= 0 ); if ( max <= self->max ) return; if ( ! ( self->str = (char *)realloc( self->str, (size_t)max ) ) ) Log_fatal( "Realloc of DynStr failed" ); if ( self->max == 0 ) /* First allocation? */ *(self->str) = '\0'; self->max = max; } DynStr * new_DynStr( int reserve ) { DynStr *s; if ( ! ( s = malloc( sizeof( DynStr ) ) ) ) Log_fatal( "Allocation of DynStr failed" ); s->len = 0; s->max = 0; s->str = NULL; if ( reserve > 0 ) reallocStr( s, reserve + 1 ); return s; } void del_DynStr( DynStr *self ) { if ( ! self ) return; free( self->str ); self->str = NULL; free( self ); } int DynStr_len( const DynStr *self ) { return self->len; } const char * DynStr_str( const DynStr *self ) { return self->str; } void DynStr_app( DynStr *self, const char *s ) { int len; len = strlen( s ); if ( self->len + len + 1 > self->max ) reallocStr( self, self->len * 2 + len + 1 ); strcpy( self->str + self->len, s ); self->len += len; } void DynStr_appDynStr( DynStr *self, const DynStr *s ) { if ( self->len + s->len + 1 > self->max ) reallocStr( self, self->len * 2 + s->len + 1 ); memcpy( self->str + self->len, s->str, (size_t)s->len + 1 ); self->len += s->len; } void DynStr_appLn( DynStr *self, const char *s ) { DynStr_app( self, s ); DynStr_app( self, "\n" ); } void DynStr_appN( DynStr *self, const char *s, int n ) { int len = self->len; ASSERT( n >= 0 ); if ( len + n + 1 > self->max ) reallocStr( self, len * 2 + n + 1 ); strncat( self->str + len, s, (size_t)n ); self->len = len + strlen( self->str + len ); } void DynStr_clear( DynStr *self ) { self->len = 0; if ( self->max > 0 ) *(self->str) = '\0'; }