[Freeciv-Dev] (PR#8570) no auth for gtk2 client
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8570 >
> [mstefek - Mon Aug 30 16:02:26 2004]:
>
> On 2004-08-30 17:19:15, Per I. Mathisen wrote:
> >
> > <URL: http://rt.freeciv.org/Ticket/Display.html?id=8570 >
> >
> > On Mon, 30 Aug 2004, Mike Kaufman wrote:
> > > 2. It would require the user to compile things like
> > server/userdb/lockfile.c
> > > into their server all the time. That might be horrible. I haven't
> > thought
> > > about it a whole lot.
> >
> > What is rarely compiled, quickly bitrots. What is often compiled, is
> > quickly fixed.
> >
> > I say put it in.
> >
> > - Per
> I think this patch will make it.
> ./configure option is still called --enable-auth[=authdb].
> (I don't know much about configure scripts)
This patch is a little better.
1. You don't need to use "x" all the time if you use quotes.
2. Variable assignments generally should use quotes.
3. The whole thing (auth.m4) was much longer than necessary.
jason
Index: m4/auth.m4
===================================================================
RCS file: /home/freeciv/CVS/freeciv/m4/auth.m4,v
retrieving revision 1.3
diff -u -r1.3 auth.m4
--- m4/auth.m4 27 Apr 2004 05:00:25 -0000 1.3
+++ m4/auth.m4 2 Sep 2004 20:33:02 -0000
@@ -1,27 +1,19 @@
-AC_DEFUN([FC_CHECK_AUTH], [
-USER_DB_LIB=""
-USER_DB_DEP=""
-AC_ARG_ENABLE(auth,
-[ --enable-auth[[=lib]] enable authentication
- [[default userdb
lib=server/userdb/libuserdb.a]]],
+# Do checks for Freeciv authentication support
+#
+# Called without any parameters.
+
+AC_DEFUN([FC_CHECK_AUTH],
[
- auth=true
- user_db_lib=${enableval}
- if test "x$user_db_lib" = "" || test "x$user_db_lib" = "xyes" ; then
- user_db_lib="userdb/libuserdb.a"
- fi
-], [
- auth=false
- user_db_lib=""
-])
-if test "x$auth" = "xtrue" ; then
- AC_DEFINE(AUTHENTICATION_ENABLED, 1, [authentication support])
- USER_DB_LIB=$user_db_lib
+ AC_ARG_ENABLE([auth],
+ AC_HELP_STRING([--enable-auth[[=lib]]],
+ [Enable authentication]),
+ [USER_DB_LIB="$enableval"], [USER_DB_LIB="yes"])
- if test "x$user_db_lib" = "xuserdb/libuserdb.a" ; then
- USER_DB_DEP=$user_db_lib
+ if test "$USER_DB_LIB" = "yes"; then
+ USER_DB_LIB="userdb/libuserdb.a"
fi
-fi
-AC_SUBST(USER_DB_LIB)
-AC_SUBST(USER_DB_DEP)
+ USER_DB_DEB="$USER_DB_LIB"
+
+ AC_SUBST(USER_DB_LIB)
+ AC_SUBST(USER_DB_DEP)
])
Index: server/civserver.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/civserver.c,v
retrieving revision 1.220
diff -u -r1.220 civserver.c
--- server/civserver.c 21 Aug 2004 18:32:37 -0000 1.220
+++ server/civserver.c 2 Sep 2004 20:33:02 -0000
@@ -109,14 +109,12 @@
showhelp = TRUE;
break;
}
-#ifdef AUTHENTICATION_ENABLED
} else if (is_option("--auth", argv[inx])) {
srvarg.auth_enabled = TRUE;
} else if (is_option("--Guests", argv[inx])) {
srvarg.auth_allow_guests = TRUE;
} else if (is_option("--Newusers", argv[inx])) {
srvarg.auth_allow_newusers = TRUE;
-#endif
} else if (is_option("--version", argv[inx]))
showvers = TRUE;
else {
@@ -137,11 +135,9 @@
if (showhelp) {
fprintf(stderr, _("Usage: %s [option ...]\nValid options are:\n"),
argv[0]);
-#ifdef AUTHENTICATION_ENABLED
fprintf(stderr, _(" -a --auth\t\tEnable server authentication.\n"));
fprintf(stderr, _(" -G --Guests\t\tAllow guests to login if auth is
enabled.\n"));
fprintf(stderr, _(" -N --Newusers\tAllow new users to login if auth is
enabled.\n"));
-#endif
fprintf(stderr, _(" -b --bind ADDR\tListen for clients on ADDR\n"));
#ifdef DEBUG
fprintf(stderr, _(" -d, --debug NUM\tSet debug log level (0 to 4,"
Index: server/connecthand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/connecthand.c,v
retrieving revision 1.22
diff -u -r1.22 connecthand.c
--- server/connecthand.c 21 Aug 2004 18:32:37 -0000 1.22
+++ server/connecthand.c 2 Sep 2004 20:33:02 -0000
@@ -49,20 +49,16 @@
#define MAX_AUTHENTICATION_TRIES 3
-#ifdef AUTHENTICATION_ENABLED
/* after each wrong guess for a password, the server waits this
* many seconds to reply to the client */
static const int auth_fail_period[] = { 1, 1, 2, 3 };
-#endif
static void establish_new_connection(struct connection *pconn);
static void reject_new_connection(const char *msg, struct connection *pconn);
-#ifdef AUTHENTICATION_ENABLED
static bool is_guest_name(const char *name);
static void get_unique_guest_name(char *name);
static bool is_good_password(const char *password, char *msg);
-#endif
/**************************************************************************
This is used when a new player joins a server, before the game
@@ -277,7 +273,6 @@
}
} conn_list_iterate_end;
-#ifdef AUTHENTICATION_ENABLED
if (srvarg.auth_enabled) {
/* assign the client a unique guest name/reject if guests aren't allowed */
if (is_guest_name(req->username)) {
@@ -350,7 +345,6 @@
return TRUE;
}
}
-#endif /* AUTHENTICATION_ENABLED */
sz_strlcpy(pconn->username, req->username);
establish_new_connection(pconn);
@@ -384,7 +378,6 @@
**************************************************************************/
bool handle_authentication_reply(struct connection *pconn, char *password)
{
-#ifdef AUTHENTICATION_ENABLED
char msg[MAX_LEN_MSG];
if (pconn->server.status == AS_REQUESTING_NEW_PASS) {
@@ -433,12 +426,8 @@
}
return TRUE;
-#else
- return FALSE;
-#endif /* AUTHENTICATION_ENABLED */
}
-#ifdef AUTHENTICATION_ENABLED
/**************************************************************************
see if the name qualifies as a guest login name
**************************************************************************/
@@ -527,7 +516,6 @@
return TRUE;
}
-#endif /* AUTHENTICATION_ENABLED */
/**************************************************************************
High-level server stuff when connection to client is closed or lost.
|
|