mirror of
https://github.com/samba-team/samba.git
synced 2025-02-05 21:57:51 +03:00
1. using smbc_getxattr() et al, one may now request all access control entities in the ACL without getting all other NT attributes. 2. added the ability to exclude specified attributes from the result set provided by smbc_getxattr() et al, when requesting all attributes, all NT attributes, or all DOS attributes. 3. eliminated all compiler warnings, including when --enable-developer compiler flags are in use. removed -Wcast-qual flag from list, as that is specifically to force warnings in the case of casting away qualifiers. Note: In the process of eliminating compiler warnings, a few nasties were discovered. In the file libads/sasl.c, PRIVATE kerberos interfaces are being used; and in libsmb/clikrb5.c, both PRIAVE and DEPRECATED kerberos interfaces are being used. Someone who knows kerberos should look at these and determine if there is an alternate method of accomplishing the task.
145 lines
3.5 KiB
C
145 lines
3.5 KiB
C
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
#include <dirent.h>
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <popt.h>
|
|
#include <stdlib.h>
|
|
#include <libsmbclient.h>
|
|
#include "get_auth_data_fn.h"
|
|
|
|
void error_message(char * pMessage)
|
|
{
|
|
printf("ERROR: %s\n", pMessage);
|
|
}
|
|
|
|
|
|
int
|
|
main(int argc, char * argv[])
|
|
{
|
|
int debug = 0;
|
|
int opt;
|
|
char * p;
|
|
char * q;
|
|
char buf[1024];
|
|
int dir;
|
|
struct stat stat;
|
|
struct smbc_dirent * dirent;
|
|
poptContext pc;
|
|
struct poptOption long_options[] =
|
|
{
|
|
POPT_AUTOHELP
|
|
{
|
|
"debug", 'd', POPT_ARG_INT, &debug,
|
|
0, "Set debug level", "integer"
|
|
},
|
|
{
|
|
NULL
|
|
}
|
|
};
|
|
|
|
setbuf(stdout, NULL);
|
|
|
|
pc = poptGetContext("opendir", argc, (const char **)argv, long_options, 0);
|
|
|
|
poptSetOtherOptionHelp(pc, "");
|
|
|
|
while ((opt = poptGetNextOpt(pc)) != -1) {
|
|
printf("Got option %d = %c\n", opt, opt);
|
|
switch (opt) {
|
|
}
|
|
}
|
|
|
|
if (smbc_init(get_auth_data_fn, debug) != 0)
|
|
{
|
|
printf("Could not initialize smbc_ library\n");
|
|
return 1;
|
|
}
|
|
|
|
for (fputs("url: ", stdout), p = fgets(buf, sizeof(buf), stdin);
|
|
p != NULL && *p != '\n' && *p != '\0';
|
|
fputs("url: ", stdout), p = fgets(buf, sizeof(buf), stdin))
|
|
{
|
|
if ((p = strchr(buf, '\n')) != NULL)
|
|
{
|
|
*p = '\0';
|
|
}
|
|
|
|
printf("Opening (%s)...\n", buf);
|
|
|
|
if ((dir = smbc_opendir(buf)) < 0)
|
|
{
|
|
printf("Could not open directory [%s] (%d:%s)\n",
|
|
buf, errno, strerror(errno));
|
|
continue;
|
|
}
|
|
|
|
while ((dirent = smbc_readdir(dir)) != NULL)
|
|
{
|
|
printf("%-30s", dirent->name);
|
|
printf("%-30s", dirent->comment);
|
|
|
|
switch(dirent->smbc_type)
|
|
{
|
|
case SMBC_WORKGROUP:
|
|
printf("WORKGROUP");
|
|
break;
|
|
|
|
case SMBC_SERVER:
|
|
printf("SERVER");
|
|
break;
|
|
|
|
case SMBC_FILE_SHARE:
|
|
printf("FILE_SHARE");
|
|
break;
|
|
|
|
case SMBC_PRINTER_SHARE:
|
|
printf("PRINTER_SHARE");
|
|
break;
|
|
|
|
case SMBC_COMMS_SHARE:
|
|
printf("COMMS_SHARE");
|
|
break;
|
|
|
|
case SMBC_IPC_SHARE:
|
|
printf("IPC_SHARE");
|
|
break;
|
|
|
|
case SMBC_DIR:
|
|
printf("DIR");
|
|
break;
|
|
|
|
case SMBC_FILE:
|
|
printf("FILE");
|
|
|
|
q = buf + strlen(buf);
|
|
strcat(q, "/");
|
|
strcat(q+1, dirent->name);
|
|
if (smbc_stat(buf, &stat) < 0)
|
|
{
|
|
printf(" unknown size (reason %d: %s)",
|
|
errno, strerror(errno));
|
|
}
|
|
else
|
|
{
|
|
printf(" size %lu", (unsigned long) stat.st_size);
|
|
}
|
|
*p = '\0';
|
|
|
|
break;
|
|
|
|
case SMBC_LINK:
|
|
printf("LINK");
|
|
break;
|
|
}
|
|
|
|
printf("\n");
|
|
}
|
|
|
|
smbc_closedir(dir);
|
|
}
|
|
|
|
exit(0);
|
|
}
|