Mercurial > noffle
comparison src/protocol.c @ 150:1c7303c71f66 noffle
[svn] * src/protocol.c: Fix bug in Prt_getLn if we should read a line
starting with '\0' - according to the leafnode mailing list,
this has been seen in the wild.
* docs/inews.1,docs/noffle.1,docs/noffle.conf.5,
packages/redhat/noffle.spec,src/configfile.h,src/configfile.c,
src/noffle.c,src/post.h,src/post.c: Removed use of getopt_long,
and added inews mode - the Noffle executable behaves
as inews is invoked as inews. This includes adding From: and
Organization: headers if necessary - add configs to override
defaults for the From: domain and specify the organization.
For all my fellow trn-heads out there, and users of any other
ageing newsreader that expects inews. Updated RPM spec to create
inews link to noffle on install.
author | bears |
---|---|
date | Thu, 26 Oct 2000 22:21:13 +0100 |
parents | 8b9366fc1361 |
children | cb799054bd61 |
comparison
equal
deleted
inserted
replaced
149:bfeea2bc09b6 | 150:1c7303c71f66 |
---|---|
1 /* | 1 /* |
2 protocol.c | 2 protocol.c |
3 | 3 |
4 $Id: protocol.c 217 2000-09-23 10:40:35Z enz $ | 4 $Id: protocol.c 227 2000-10-26 21:21:13Z bears $ |
5 */ | 5 */ |
6 | 6 |
7 #if HAVE_CONFIG_H | 7 #if HAVE_CONFIG_H |
8 #include <config.h> | 8 #include <config.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include <stdio.h> | 11 #include <stdio.h> |
12 #include <ctype.h> | 12 #include <ctype.h> |
13 #include <netdb.h> | 13 #include <netdb.h> |
14 #include <pwd.h> | |
14 #include <signal.h> | 15 #include <signal.h> |
15 #include <sys/types.h> | 16 #include <sys/types.h> |
16 #include <sys/utsname.h> | 17 #include <sys/utsname.h> |
17 #include <unistd.h> | 18 #include <unistd.h> |
18 #include "common.h" | 19 #include "common.h" |
77 installSignalHandler( SIGALRM, oldHandler ); | 78 installSignalHandler( SIGALRM, oldHandler ); |
78 } | 79 } |
79 if ( ret == NULL ) | 80 if ( ret == NULL ) |
80 return FALSE; | 81 return FALSE; |
81 len = strlen( line ); | 82 len = strlen( line ); |
82 if ( line[ len - 1 ] == '\n' ) | 83 if ( len > 0 && line[ len - 1 ] == '\n' ) |
83 { | 84 { |
84 line[ len - 1 ] = '\0'; | 85 line[ len - 1 ] = '\0'; |
85 if ( line[ len - 2 ] == '\r' ) | 86 if ( len > 1 && line[ len - 2 ] == '\r' ) |
86 line[ len - 2 ] = '\0'; | 87 line[ len - 2 ] = '\0'; |
87 } | 88 } |
88 Log_dbg( "[R] %s", line ); | 89 Log_dbg( "[R] %s", line ); |
89 return TRUE; | 90 return TRUE; |
90 } | 91 } |
342 { | 343 { |
343 getDomain( pathHdr, from ); | 344 getDomain( pathHdr, from ); |
344 Utl_catStr( pathHdr, "!not-for-mail" ); | 345 Utl_catStr( pathHdr, "!not-for-mail" ); |
345 } | 346 } |
346 | 347 |
347 | 348 Bool |
348 | 349 Prt_genFromHdr( Str fromHdr ) |
349 | 350 { |
351 Str name, domain; | |
352 const char *nameval; | |
353 struct passwd *pwd; | |
354 | |
355 /* First get the domain to use. If config empty, use FQDN */ | |
356 Utl_cpyStr( domain, Cfg_fromDomain() ); | |
357 | |
358 if ( DynStr_len( domain ) == 0 ) | |
359 if ( ! getFQDN( domain ) ) | |
360 Utl_catStr( domain, "unknown" ); | |
361 | |
362 /* Now get pwd for the username */ | |
363 pwd = getpwuid( getuid() ); | |
364 if ( pwd == NULL ) | |
365 return FALSE; | |
366 | |
367 /* Now for their name - use env NAME if available */ | |
368 nameval = getenv( "NAME" ); | |
369 if ( nameval != NULL ) | |
370 Utl_cpyStr( name, nameval ); | |
371 else | |
372 { | |
373 char *p; | |
374 | |
375 /* | |
376 Extract from GECOS field. Following the lead of the INN inews, | |
377 ignore leading stuff like "23-" "stuff]-" or "stuff -" as well | |
378 as trailing whitespace, or anything that comes after | |
379 a comma or semicolon. | |
380 */ | |
381 nameval = pwd->pw_gecos; | |
382 p = strchr( nameval, '-' ); | |
383 if ( p != NULL && p > nameval && | |
384 ( p[-1] == ']' || p[-1] == ' ' || isdigit( p[ -1 ] ) ) ) | |
385 nameval = p; | |
386 p = strrchr( nameval, ',' ); | |
387 if ( p != NULL ) | |
388 *p = '\0'; | |
389 p = strchr( nameval, ';' ); | |
390 if ( p != NULL ) | |
391 *p = '\0'; | |
392 Utl_cpyStr( name, nameval ); | |
393 } | |
394 | |
395 /* OK, build From: contents */ | |
396 Utl_cpyStr( fromHdr, pwd->pw_name ); | |
397 Utl_catStr( fromHdr, "@" ); | |
398 Utl_catStr( fromHdr, domain ); | |
399 Utl_catStr( fromHdr, " (" ); | |
400 Utl_catStr( fromHdr, name ); | |
401 Utl_catStr( fromHdr, ")" ); | |
402 | |
403 return TRUE; | |
404 } | |
405 | |
406 | |
407 |