Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] Building mosquitto auth-plugin.

Dear Matt , I really appreciate your help on this.
I have never solve this by mi self.
mosquitto is great tool , I think auth plug in should be buiilted in.
THANKSSSSS!.

El vie., 7 feb. 2020 a las 11:47, Matt Woelfel (<matt@xxxxxxxxxxxxx>) escribió:
mosquitto-auth-plug is getting a little out of date with upstream Mosquitto and the API signatures are different.

I did this on Fedora 31.  CentOS shouldn't be too different.

cd mosquitto-auth-plug
sudo dnf install mosquitto-devel mysql-devel -y    # use `yum` instead of `dnf` if appropriate

You should only need to build Mosquitto if you require a newer version than what's in the CentOS repo.  It looks like 1.6.8 is packaged in the EPEL (https://fedoraproject.org/wiki/EPEL).

Apply the following changes to mosquitto-auth-plug:
```
diff --git a/auth-plug.c b/auth-plug.c
index 735589f..85e3f41 100644
--- a/auth-plug.c
+++ b/auth-plug.c
@@ -498,7 +498,9 @@ int mosquitto_auth_security_cleanup(void *userdata, struct mosquitto_auth_opt *a
 }
 
 
-#if MOSQ_AUTH_PLUGIN_VERSION >=3
+#if MOSQ_AUTH_PLUGIN_VERSION >=4
+int mosquitto_auth_unpwd_check(void *userdata, struct mosquitto *client, const char *username, const char *password)
+#elif MOSQ_AUTH_PLUGIN_VERSION >=3
 int mosquitto_auth_unpwd_check(void *userdata, const struct mosquitto *client, const char *username, const char *password)
 #else
 int mosquitto_auth_unpwd_check(void *userdata, const char *username, const char *password)
@@ -597,7 +599,9 @@ int mosquitto_auth_unpwd_check(void *userdata, const char *username, const char
        return granted;
 }
 
-#if MOSQ_AUTH_PLUGIN_VERSION >= 3
+#if MOSQ_AUTH_PLUGIN_VERSION >= 4
+int mosquitto_auth_acl_check(void *userdata, int access, struct mosquitto *client, const struct mosquitto_acl_msg *msg)
+#elif MOSQ_AUTH_PLUGIN_VERSION >= 3
 int mosquitto_auth_acl_check(void *userdata, int access, const struct mosquitto *client, const struct mosquitto_acl_msg *msg)
 #else
 int mosquitto_auth_acl_check(void *userdata, const char *clientid, const char *username, const char *topic, int access)
@@ -748,7 +752,9 @@ int mosquitto_auth_acl_check(void *userdata, const char *clientid, const char *u
 }
 
 
-#if MOSQ_AUTH_PLUGIN_VERSION >= 3
+#if MOSQ_AUTH_PLUGIN_VERSION >= 4
+int mosquitto_auth_psk_key_get(void *userdata, struct mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len)
+#elif MOSQ_AUTH_PLUGIN_VERSION >= 3
 int mosquitto_auth_psk_key_get(void *userdata, const struct mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len)
 #else
 int mosquitto_auth_psk_key_get(void *userdata, const char *hint, const char *identity, char *key, int max_key_len)
```

mosquitto-auth-plug built cleanly for me.  I didn't install or test it.

On Thu, Feb 6, 2020 at 9:01 PM Leandro Roggerone <ingrogger@xxxxxxxxx> wrote:
Hi guys ... I can not build mosquitto auth plugin on my centos 7 server.
This is what im doing:

cd /usr/src/
git clone https://github.com/eclipse/mosquitto.git
git clone https://github.com/jpmens/mosquitto-auth-plug.git
cd  mosquitto-auth-plug/
cp config.mk.in config.mk
vim config.mk
:
###############
BACKEND_MYSQL ?= yes
.
# Specify the path to the Mosquitto sources here
# MOSQUITTO_SRC = /usr/local/Cellar/mosquitto/1.4.12
MOSQUITTO_SRC = /usr/src/mosquitto

# Specify the path the OpenSSL here
OPENSSLDIR = /usr/bin
###############

then :
make , yelds:

Selected backends:          MySQL
Using mosquitto source dir: /usr/src/mosquitto
OpenSSL install dir:        /usr/bin

If you changed the backend selection, you might need to 'make clean' first

CFLAGS:   -I/usr/src/mosquitto/src/ -I/usr/src/mosquitto/lib/ -fPIC -Wall -Werror  -DBE_MYSQL  -I/usr/include/mysql -m64  -I/src -DDEBUG=1 -I/usr/bin/include
LDFLAGS:   -L/usr/src/mosquitto/lib/
LDADD:    -L/usr/lib64/mysql -lmysqlclient -lpthread -lm -lrt -ldl -L/usr/bin/lib -lcrypto -lmosquitto

cc  -I/usr/src/mosquitto/src/ -I/usr/src/mosquitto/lib/ -fPIC -Wall -Werror  -DBE_MYSQL  `mysql_config --cflags` -I/src -DDEBUG=1 -I/usr/bin/include   -c -o auth-plug.o auth-plug.c
auth-plug.c:502:5: error: conflicting types for ‘mosquitto_auth_unpwd_check’
 int mosquitto_auth_unpwd_check(void *userdata, const struct mosquitto *client, const char *username, const char *password)
     ^
In file included from auth-plug.c:36:0:
/usr/src/mosquitto/src/mosquitto_plugin.h:254:5: note: previous declaration of ‘mosquitto_auth_unpwd_check’ was here
 int mosquitto_auth_unpwd_check(void *user_data, struct mosquitto *client, const char *username, const char *password);
     ^
auth-plug.c:601:5: error: conflicting types for ‘mosquitto_auth_acl_check’
 int mosquitto_auth_acl_check(void *userdata, int access, const struct mosquitto *client, const struct mosquitto_acl_msg *msg)
     ^
In file included from auth-plug.c:36:0:
/usr/src/mosquitto/src/mosquitto_plugin.h:237:5: note: previous declaration of ‘mosquitto_auth_acl_check’ was here
 int mosquitto_auth_acl_check(void *user_data, int access, struct mosquitto *client, const struct mosquitto_acl_msg *msg);
     ^
auth-plug.c:752:5: error: conflicting types for ‘mosquitto_auth_psk_key_get’
 int mosquitto_auth_psk_key_get(void *userdata, const struct mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len)
     ^
In file included from auth-plug.c:36:0:
/usr/src/mosquitto/src/mosquitto_plugin.h:282:5: note: previous declaration of ‘mosquitto_auth_psk_key_get’ was here
 int mosquitto_auth_psk_key_get(void *user_data, struct mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len);
     ^
make: *** [auth-plug.o] Error 1

Question:
Do I need to build mosquitto also ? (It works out of the box using yum install mosquitto).
Is it easier to install in other distro ? debian perhaps ?.
Any help would be great!!!
Thanks.

_______________________________________________
mosquitto-dev mailing list
mosquitto-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/mosquitto-dev
_______________________________________________
mosquitto-dev mailing list
mosquitto-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/mosquitto-dev

Back to the top