commit - 761b2284b953de0d5c2f847e55e3fbc030243178
commit + 1995af0ed62a4bbf544e0b5d9e0613fc912c9e3b
blob - e6dbf1563c78e1f919954b91400a040d8b997d73
blob + 44123eaa0b8d9af5444f0098b5fe1d656017b2b2
--- src/ngircd/client.c
+++ src/ngircd/client.c
client->type = Type;
if (ID)
Client_SetID(client, ID);
- if (User)
+ if (User) {
Client_SetUser(client, User, Idented);
+ Client_SetOrigUser(client, User);
+ }
if (Hostname)
Client_SetHostname(client, Hostname);
if (Info)
strlcpy(Client->user + 1, User, sizeof(Client->user) - 1);
}
} /* Client_SetUser */
+
+
+/**
+ * Set "original" user name of a client.
+ * This function saves the "original" user name, the user name specified by
+ * the peer using the USER command, into the CLIENT structure. This user
+ * name may be used for authentication, for example.
+ * @param Client The client.
+ * @param User User name to set.
+ */
+GLOBAL void
+Client_SetOrigUser(CLIENT *Client, const char *User) {
+ assert(Client != NULL);
+ assert(User != NULL);
+#ifdef PAM & IDENTAUTH
+ strlcpy(Client->orig_user, User, sizeof(Client->orig_user));
+#endif
+} /* Client_SetOrigUser */
+
GLOBAL void
Client_SetInfo( CLIENT *Client, const char *Info )
{
assert( Client != NULL );
return Client->user[0] ? Client->user : "~";
} /* Client_User */
+
+
+#ifdef PAM
+/**
+ * Get the "original" user name as supplied by the USER command.
+ * The user name as given by the client is used for authentication instead
+ * of the one detected using IDENT requests.
+ * @param Client The client.
+ * @return Original user name.
+ */
+GLOBAL char *
+Client_OrigUser(CLIENT *Client) {
+#ifndef IDENTAUTH
+ char *user = Client->user;
+ if (user[0] == '~')
+ user++;
+ return user;
+#else
+ return Client->orig_user;
+#endif
+} /* Client_OrigUser */
+
+#endif
+
+
GLOBAL char *
Client_Hostname( CLIENT *Client )
{
blob - 90fd6f286832a3d2faf67bc22b15b58b42d35b58
blob + 352ddf3898550b28f19baeca77558f8bd808f3c4
--- src/ngircd/client.h
+++ src/ngircd/client.h
char pwd[CLIENT_PASS_LEN]; /* password received of the client */
char host[CLIENT_HOST_LEN]; /* hostname of the client */
char user[CLIENT_USER_LEN]; /* user name ("login") */
+#ifdef PAM & IDENTAUTH
+ char orig_user[CLIENT_USER_LEN];/* user name supplied by USER command */
+#endif
char info[CLIENT_INFO_LEN]; /* long user name (user) / info text (server) */
char modes[CLIENT_MODE_LEN]; /* client modes */
int hops, token, mytoken; /* "hops" and "Token" (see SERVER command) */
GLOBAL char *Client_Mask PARAMS(( CLIENT *Client ));
GLOBAL char *Client_Info PARAMS(( CLIENT *Client ));
GLOBAL char *Client_User PARAMS(( CLIENT *Client ));
+#ifdef PAM
+GLOBAL char *Client_OrigUser PARAMS(( CLIENT *Client ));
+#endif
GLOBAL char *Client_Hostname PARAMS(( CLIENT *Client ));
GLOBAL char *Client_Password PARAMS(( CLIENT *Client ));
GLOBAL char *Client_Modes PARAMS(( CLIENT *Client ));
GLOBAL void Client_SetHostname PARAMS(( CLIENT *Client, const char *Hostname ));
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 ));
GLOBAL void Client_SetInfo PARAMS(( CLIENT *Client, const char *Info ));
GLOBAL void Client_SetPassword PARAMS(( CLIENT *Client, const char *Pwd ));
GLOBAL void Client_SetType PARAMS(( CLIENT *Client, int Type ));
blob - 5a52d3cb68a9955079e75d4053f50ca61841ef19
blob + 906b669ba3f748210fe9849db1e2ca4ed5cba46e
--- src/ngircd/irc-login.c
+++ src/ngircd/irc-login.c
#else
Client_SetUser(Client, Req->argv[0], false);
#endif
+ Client_SetOrigUser(Client, Req->argv[0]);
/* "Real name" or user info text: Don't set it to the empty
* string, the original ircd can't deal with such "real names"
Req->prefix);
Client_SetUser(c, Req->argv[0], true);
+ Client_SetOrigUser(c, Req->argv[0]);
Client_SetHostname(c, Req->argv[1]);
Client_SetInfo(c, Req->argv[3]);
Client_Conn(Client), Req->argv[1], Req->argv[2], Req->argv[3]);
Client_SetUser(Client, Req->argv[1], true);
+ Client_SetOrigUser(Client, Req->argv[1]);
Client_SetHostname(Client, Req->argv[2]);
return CONNECTED;
} /* IRC_WEBIRC */