patrick keshishian wrote:
On Wed, May 27, 2009 at 12:09:45PM +0300, Gregory Edigarov wrote:
Sorry for the first one.
If there's something wrong with style again, please tell me exactly
what. I will edit it again.
--
With best regards,
Gregory Edigarov
--- smtpd.c.orig Tue May 26 23:11:26 2009
+++ smtpd.c.new Wed May 27 12:04:17 2009
@@ -83,6 +83,52 @@
extern char **environ;
+char *executable = "/usr/libexec/smtpd-auth";
+char *plugin = "/usr/libexec/smtpd-auth.so";
+
+/*
+ * athenticate through custom executable
+ */
+
+int auth_exec (char *executable, char *user, char *passwd)
+{
+ pid_t a_pid;
+ int r;
+
+ if( ( a_pid = fork()) == 0)
+ execl(executable,executable,user,passwd);
+ else
+ r = wait();
Consider the case when fork() may fail. Also, wait(2) takes
an argument.
+/*
+ * authenticate using plugin
+ */
+
+int auth_plugin (char *plugin, char *user, char *passwd)
+{
+ void *handle;
+ int (*smtp_authenticate) (char*, char*); /* plugin must export this function */
+ int r;
+
+ handle = dlopen (plugin,RTLD_NOW);
+ if (!handle) {
+ /* perhaps should log something before */
+ return 0;
+ }
+
+ smtp_authenticate = dlsym(handle,"smtp_authenticate");
+ if ((error = dlerror()) != NULL) {
^^^^^
is 'error' a global variable?
--patrick
Oh, shit. my bad :-(
but then again, after i discussed it with gilles@, i withdraw it, and
will do login_smtp with the same functionality.
--
With best regards,
Gregory Edigarov