Module: ngircd.git
Branch: master
Commit: 41f75b69740bd205864bd34afbb65ab0a3776136
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=41f75b69…
Author: Alexander Barton <alex(a)barton.de>
Date: Tue Aug 27 00:39:59 2013 +0200
Ignore "operation not permitted" while dropping groups
Without this exception, you can't start ngIRCd as user any more,
it is analog to setting the user and group ID.
---
src/ngircd/ngircd.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c
index 4099719..e26ac3b 100644
--- a/src/ngircd/ngircd.c
+++ b/src/ngircd/ngircd.c
@@ -725,9 +725,11 @@ NGIRCd_Init(bool NGIRCd_NoDaemon)
goto out;
}
if (setgroups(0, NULL) != 0) {
- Log(LOG_ERR, "Can't drop supplementary group ids: %s!",
+ real_errno = errno;
+ Log(LOG_ERR, "Can't drop supplementary group IDs: %s!",
strerror(errno));
- goto out;
+ if (real_errno != EPERM)
+ goto out;
}
}
#endif
Module: ngircd.git
Branch: master
Commit: 44698e44e8a9bf9f3a1211e10b4d59e00be5864f
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=44698e44…
Author: Alexander Barton <alex(a)barton.de>
Date: Mon Aug 26 23:22:20 2013 +0200
Merge branch 'bug159-WebircIPA'
* bug159-WebircIPA:
Introduce Free_Client() function to free CLIENT structure
Save client IP address text for "WebIRC" users
---
Module: ngircd.git
Branch: master
Commit: 1dc93286a0d5b80259604b4f25021fcc5a730b5b
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=1dc93286…
Author: Alexander Barton <alex(a)barton.de>
Date: Mon Aug 26 22:54:00 2013 +0200
Save client IP address text for "WebIRC" users
This patch introduces a new field in the CLIENT structure, "ipa_text",
which points to an optional textual representation of the client IP
address (or NULL) which can be used to store the "real" IP address
information of a client using the "WEBIRC" protocol.
Without this patch, ngIRCd ignored the <ip-address> paramater ...
In addition, the functions Client_SetIPAText() and Client_IPAText()
have been introduced to set and get the textual representation of the
client IP address.
Client_IPAText() can be used even when no "IP address text" has been
set before, it then returns the real IP address of the connection.
Closes bug #159.
---
src/ngircd/client.c | 40 ++++++++++++++++++++++++++++++++++++++++
src/ngircd/client.h | 5 ++++-
src/ngircd/irc-info.c | 4 ++--
src/ngircd/irc-login.c | 2 ++
4 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/src/ngircd/client.c b/src/ngircd/client.c
index 72774ca..26d4929 100644
--- a/src/ngircd/client.c
+++ b/src/ngircd/client.c
@@ -128,6 +128,8 @@ Client_Exit( void )
free(c->account_name);
if (c->cloaked)
free(c->cloaked);
+ if (c->ipa_text)
+ free(c->ipa_text);
free( c );
c = next;
}
@@ -326,6 +328,8 @@ Client_Destroy( CLIENT *Client, const char *LogMsg, const char *FwdMsg, bool Sen
free(c->account_name);
if (c->cloaked)
free(c->cloaked);
+ if (c->ipa_text)
+ free(c->ipa_text);
free( c );
break;
}
@@ -368,6 +372,27 @@ Client_SetHostname( CLIENT *Client, const char *Hostname )
} /* Client_SetHostname */
+/**
+ * Set IP address to display for a client.
+ *
+ * @param Client The client.
+ * @param IPAText Textual representation of the IP address or NULL to unset.
+ */
+GLOBAL void
+Client_SetIPAText(CLIENT *Client, const char *IPAText)
+{
+ assert(Client != NULL);
+
+ if (Client->ipa_text)
+ free(Client->ipa_text);
+
+ if (*IPAText)
+ Client->ipa_text = strndup(IPAText, CLIENT_HOST_LEN - 1);
+ else
+ Client->ipa_text = NULL;
+}
+
+
GLOBAL void
Client_SetID( CLIENT *Client, const char *ID )
{
@@ -789,6 +814,21 @@ Client_HostnameDisplayed(CLIENT *Client)
return Client->cloaked;
}
+GLOBAL const char *
+Client_IPAText(CLIENT *Client)
+{
+ assert(Client != NULL);
+
+ /* Not a local client? */
+ if (Client_Conn(Client) <= NONE)
+ return "0.0.0.0";
+
+ if (!Client->ipa_text)
+ return Conn_GetIPAInfo(Client_Conn(Client));
+ else
+ return Client->ipa_text;
+}
+
/**
* Update (and generate, if necessary) the cloaked hostname of a client.
*
diff --git a/src/ngircd/client.h b/src/ngircd/client.h
index 702f114..71d413b 100644
--- a/src/ngircd/client.h
+++ b/src/ngircd/client.h
@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2012 Alexander Barton (alex(a)barton.de)
+ * Copyright (c)2001-2013 Alexander Barton (alex(a)barton.de) and Contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -49,6 +49,7 @@ typedef struct _CLIENT
struct _CLIENT *topserver; /* toplevel servers (only valid if client is a server) */
char host[CLIENT_HOST_LEN]; /* hostname of the client */
char *cloaked; /* cloaked hostname of the client */
+ char *ipa_text; /* textual representaton of IP address */
char user[CLIENT_USER_LEN]; /* user name ("login") */
#if defined(PAM) && defined(IDENTAUTH)
char orig_user[CLIENT_USER_LEN];/* user name supplied by USER command */
@@ -114,6 +115,7 @@ GLOBAL char *Client_OrigUser PARAMS(( CLIENT *Client ));
GLOBAL char *Client_Hostname PARAMS(( CLIENT *Client ));
GLOBAL char *Client_HostnameCloaked PARAMS((CLIENT *Client));
GLOBAL char *Client_HostnameDisplayed PARAMS(( CLIENT *Client ));
+GLOBAL const char *Client_IPAText PARAMS(( CLIENT *Client ));
GLOBAL char *Client_Modes PARAMS(( CLIENT *Client ));
GLOBAL char *Client_Flags PARAMS(( CLIENT *Client ));
GLOBAL CLIENT *Client_Introducer PARAMS(( CLIENT *Client ));
@@ -131,6 +133,7 @@ GLOBAL bool Client_HasMode PARAMS(( CLIENT *Client, char Mode ));
GLOBAL bool Client_HasFlag PARAMS(( CLIENT *Client, char Flag ));
GLOBAL void Client_SetHostname PARAMS(( CLIENT *Client, const char *Hostname ));
+GLOBAL void Client_SetIPAText PARAMS(( CLIENT *Client, const char *IPAText ));
GLOBAL void Client_SetID PARAMS(( CLIENT *Client, const char *Nick ));
GLOBAL void Client_SetUser PARAMS(( CLIENT *Client, const char *User, bool Idented ));
GLOBAL void Client_SetOrigUser PARAMS(( CLIENT *Client, const char *User ));
diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c
index 47a3797..3d77237 100644
--- a/src/ngircd/irc-info.c
+++ b/src/ngircd/irc-info.c
@@ -407,8 +407,8 @@ IRC_WHOIS_SendReply(CLIENT *Client, CLIENT *from, CLIENT *c)
(from == c || (!Conf_MorePrivacy && Client_HasMode(from, 'o')))) {
/* Client hostname */
if (!IRC_WriteStrClient(from, RPL_WHOISHOST_MSG,
- Client_ID(from), Client_ID(c), Client_Hostname(c),
- Conn_GetIPAInfo(Client_Conn(c))))
+ Client_ID(from), Client_ID(c),
+ Client_Hostname(c), Client_IPAText(c)))
return DISCONNECTED;
/* Client modes */
if (!IRC_WriteStrClient(from, RPL_WHOISMODES_MSG,
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index 26dae6b..88804ef 100644
--- a/src/ngircd/irc-login.c
+++ b/src/ngircd/irc-login.c
@@ -610,6 +610,8 @@ IRC_WEBIRC(CLIENT *Client, REQUEST *Req)
Client_SetUser(Client, Req->argv[1], true);
Client_SetOrigUser(Client, Req->argv[1]);
Client_SetHostname(Client, Req->argv[2]);
+ Client_SetIPAText(Client, Req->argv[3]);
+
return CONNECTED;
} /* IRC_WEBIRC */
Module: ngircd.git
Branch: master
Commit: 2bacb8210b4f0807eb50587bcc4329c7ea7a50c3
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=2bacb821…
Author: Alexander Barton <alex(a)barton.de>
Date: Mon Aug 26 21:17:10 2013 +0200
Implement new configuration option "DefaultUserModes"
The new configuration option "DefaultUserModes" lists user modes that
become automatically set on new local clients right after login.
Please note that only modes can be set that the client could set on
itself, you can't set "a" (away) or "o" (IRC Op), for example! User
modes "i" (invisible) or "x" (cloaked) etc. are "interesting", though.
Default: set no modes (like without this patch).
Closes bug #160.
---
doc/sample-ngircd.conf.tmpl | 7 ++++++-
man/ngircd.conf.5.tmpl | 6 ++++++
src/ngircd/conf.c | 26 ++++++++++++++++++++++++++
src/ngircd/conf.h | 3 +++
src/ngircd/login.c | 18 ++++++++++++++++--
5 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/doc/sample-ngircd.conf.tmpl b/doc/sample-ngircd.conf.tmpl
index 99960e9..ae1b213 100644
--- a/doc/sample-ngircd.conf.tmpl
+++ b/doc/sample-ngircd.conf.tmpl
@@ -165,7 +165,12 @@
;ConnectIPv6 = yes
;ConnectIPv4 = yes
- # Do any DNS lookups when a client connects to the server.
+ # Default user mode(s) to set on new local clients. Please note that
+ # only modes can be set that the client could set on itself, you can't
+ # set "a" (away) or "o" (IRC Op), for example! Default: none.
+ ;DefaultUserModes = i
+
+ # Do DNS lookups when a client connects to the server.
;DNS = yes
# Do IDENT lookups if ngIRCd has been compiled with support for it.
diff --git a/man/ngircd.conf.5.tmpl b/man/ngircd.conf.5.tmpl
index c9d7bf8..cf926f9 100644
--- a/man/ngircd.conf.5.tmpl
+++ b/man/ngircd.conf.5.tmpl
@@ -258,6 +258,12 @@ Set this to no if you do not want ngIRCd to connect to other IRC servers using
the IPv6 protocol.
Default: yes.
.TP
+\fBDefaultUserModes\fR (string)
+Default user mode(s) to set on new local clients. Please note that only modes
+can be set that the client could set on itself, you can't set "a" (away) or
+"o" (IRC Op), for example!
+Default: none.
+.TP
\fBDNS\fR (boolean)
If set to false, ngIRCd will not make any DNS lookups when clients connect.
If you configure the daemon to connect to other servers, ngIRCd may still
diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
index 79376b8..b10f490 100644
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -402,6 +402,7 @@ Conf_Test( void )
printf(" ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6));
printf(" ConnectIPv6 = %s\n", yesno_to_str(Conf_ConnectIPv4));
#endif
+ printf(" DefaultUserModes = %s\n", Conf_DefaultUserModes);
printf(" DNS = %s\n", yesno_to_str(Conf_DNS));
#ifdef IDENT
printf(" Ident = %s\n", yesno_to_str(Conf_Ident));
@@ -776,6 +777,7 @@ Set_Defaults(bool InitServers)
#else
Conf_ConnectIPv6 = false;
#endif
+ strcpy(Conf_DefaultUserModes, "");
Conf_DNS = true;
#ifdef IDENTAUTH
Conf_Ident = true;
@@ -1706,6 +1708,30 @@ Handle_OPTIONS(const char *File, int Line, char *Var, char *Arg)
Conf_ConnectIPv4 = Check_ArgIsTrue(Arg);
return;
}
+ if (strcasecmp(Var, "DefaultUserModes") == 0) {
+ p = Arg;
+ Conf_DefaultUserModes[0] = '\0';
+ while (*p) {
+ if (strchr(Conf_DefaultUserModes, *p)) {
+ /* Mode is already included; ignore it */
+ p++;
+ continue;
+ }
+
+ if (strchr(USERMODES, *p)) {
+ len = strlen(Conf_DefaultUserModes) + 1;
+ assert(len < sizeof(Conf_DefaultUserModes));
+ Conf_DefaultUserModes[len - 1] = *p;
+ Conf_DefaultUserModes[len] = '\0';
+ } else {
+ Config_Error(LOG_WARNING,
+ "%s, line %d: Unknown user mode \"%c\" in \"DefaultUserModes\"!",
+ File, Line, *p);
+ }
+ p++;
+ }
+ return;
+ }
if (strcasecmp(Var, "DNS") == 0) {
Conf_DNS = Check_ArgIsTrue(Arg);
return;
diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h
index 93d6785..948749d 100644
--- a/src/ngircd/conf.h
+++ b/src/ngircd/conf.h
@@ -202,6 +202,9 @@ GLOBAL bool Conf_PAMIsOptional;
/** Disable all CTCP commands except for /me ? */
GLOBAL bool Conf_ScrubCTCP;
+/** Default user modes for new local clients */
+GLOBAL char Conf_DefaultUserModes[CLIENT_MODE_LEN];
+
/*
* try to connect to remote systems using the ipv6 protocol,
* if they have an ipv6 address? (default yes)
diff --git a/src/ngircd/login.c b/src/ngircd/login.c
index bbde635..4011b8b 100644
--- a/src/ngircd/login.c
+++ b/src/ngircd/login.c
@@ -19,6 +19,7 @@
#include "imp.h"
#include <assert.h>
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
@@ -37,6 +38,7 @@
#include "ngircd.h"
#include "pam.h"
#include "irc-info.h"
+#include "irc-mode.h"
#include "irc-write.h"
#include "exp.h"
@@ -151,6 +153,9 @@ Login_User(CLIENT * Client)
GLOBAL bool
Login_User_PostAuth(CLIENT *Client)
{
+ REQUEST Req;
+ char modes[CLIENT_MODE_LEN + 1];
+
assert(Client != NULL);
if (Class_HandleServerBans(Client) != CONNECTED)
@@ -185,8 +190,17 @@ Login_User_PostAuth(CLIENT *Client)
if (!IRC_Show_MOTD(Client))
return DISCONNECTED;
- /* Suspend the client for a second ... */
- IRC_SetPenalty(Client, 1);
+ /* Set default user modes */
+ if (Conf_DefaultUserModes[0]) {
+ snprintf(modes, sizeof(modes), "+%s", Conf_DefaultUserModes);
+ Req.prefix = Client_ThisServer();
+ Req.command = "MODE";
+ Req.argc = 2;
+ Req.argv[0] = Client_ID(Client);
+ Req.argv[1] = modes;
+ IRC_MODE(Client, &Req);
+ } else
+ IRC_SetPenalty(Client, 1);
return CONNECTED;
}