Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
libsmbclient: SMBC_module_init() call does not init global parameters if $HOME is not set
/* https://bugzilla.samba.org/show_bug.cgi?id=9038 */
#include <stdio.h>
#include <stdlib.h>
#include <libsmbclient.h>
char *url;
void smbc_auth_fn(SMBCCTX *smbcctx,
const char *server, const char *share,
char *workgroup, int wgmaxlen,
char *username, int unmaxlen,
char *password, int pwmaxlen)
{
workgroup[0] = '\0';
username[0] = '\0';
password[0] = '\0';
}
void smbc_test(int n)
{
SMBCCTX *smbcctx;
SMBCFILE *smbcfile;
smbc_opendir_fn opendir_fn;
printf("Test %d\n", n);
smbcctx = smbc_new_context();
smbc_init_context(smbcctx);
smbc_setFunctionAuthDataWithContext(smbcctx, smbc_auth_fn);
opendir_fn = smbc_getFunctionOpendir(smbcctx);
smbcfile = (*opendir_fn)(smbcctx, url);
smbc_free_context(smbcctx, 1);
}
int main(int argc, char **argv)
{
if (argc < 2) {
printf("Usage: %s SMB_URL\n", argv[0]);
exit(1);
}
url = argv[1];
smbc_test(1);
smbc_test(2);
unsetenv("HOME");
smbc_test(3);
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment