--- /dev/null
+/*
+ Unix SMB/Netbios implementation.
+ Version 2.0
+ SMB wrapper functions
+ Copyright (C) Andrew Tridgell 1998
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "wrapper.h"
+
+ int chmod(const char *name,mode_t mode)
+{
+ if (smbw_path(name)) {
+ return smbw_chmod(name, mode);
+ }
+
+ return real_chmod(name, mode);
+}
+
--- /dev/null
+/*
+ Unix SMB/Netbios implementation.
+ Version 2.0
+ SMB wrapper functions
+ Copyright (C) Andrew Tridgell 1998
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "wrapper.h"
+
+ int chown(const char *name,uid_t owner, gid_t group)
+{
+ if (smbw_path(name)) {
+ return smbw_chown(name, owner, group);
+ }
+
+ return real_chown(name, owner, group);
+}
+
char *p, *p2;
int len;
+ *server = *share = *path = 0;
+
if (fname[0] == '/') {
pstrcpy(s, fname);
} else {
fstring server, share;
pstring s;
char *cwd;
- int l;
+ int l=strlen(SMBW_PREFIX)-1;
+
+ if (path[0] == '/' && strncmp(path,SMBW_PREFIX,l)) {
+ return False;
+ }
if (smbw_busy) return False;
cwd = smbw_parse_path(path, server, share, s);
- l = strlen(SMBW_PREFIX)-1;
-
if (strncmp(cwd,SMBW_PREFIX,l) == 0 &&
(cwd[l] == '/' || cwd[l] == 0)) {
return True;
goto failed;
}
+ /* some programs play with file descriptors fairly intimately. We
+ try to get out of the way by duping to a high fd number */
+ if (fcntl(SMBW_CLI_FD, F_GETFD) && errno == EBADF) {
+ if (dup2(srv->cli.fd, SMBW_CLI_FD) == SMBW_CLI_FD) {
+ close(srv->cli.fd);
+ srv->cli.fd = SMBW_CLI_FD;
+ }
+ }
+
DLIST_ADD(smbw_srvs, srv);
return srv;
smbw_busy--;
return -1;
}
+
+
+/*****************************************************
+a wrapper for utime()
+*******************************************************/
+int smbw_utime(const char *fname, struct utimbuf *buf)
+{
+ struct smbw_server *srv;
+ fstring server, share;
+ pstring path;
+ uint32 mode;
+
+ DEBUG(4,("%s (%s)\n", __FUNCTION__, fname));
+
+ if (!fname) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ smbw_init();
+
+ smbw_busy++;
+
+ /* work out what server they are after */
+ smbw_parse_path(fname, server, share, path);
+
+ /* get a connection to the server */
+ srv = smbw_server(server, share);
+ if (!srv) {
+ /* smbw_server sets errno */
+ goto failed;
+ }
+
+ if (!cli_getatr(&srv->cli, path, &mode, NULL, NULL)) {
+ errno = smbw_errno(&srv->cli);
+ goto failed;
+ }
+
+ if (!cli_setatr(&srv->cli, path, mode, buf->modtime)) {
+ errno = smbw_errno(&srv->cli);
+ goto failed;
+ }
+
+ smbw_busy--;
+ return 0;
+
+ failed:
+ smbw_busy--;
+ return -1;
+}
+
+/*****************************************************
+a wrapper for chown()
+*******************************************************/
+int smbw_chown(const char *fname, uid_t owner, gid_t group)
+{
+ struct smbw_server *srv;
+ fstring server, share;
+ pstring path;
+ uint32 mode;
+
+ DEBUG(4,("%s (%s)\n", __FUNCTION__, fname));
+
+ if (!fname) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ smbw_init();
+
+ smbw_busy++;
+
+ /* work out what server they are after */
+ smbw_parse_path(fname, server, share, path);
+
+ /* get a connection to the server */
+ srv = smbw_server(server, share);
+ if (!srv) {
+ /* smbw_server sets errno */
+ goto failed;
+ }
+
+ if (!cli_getatr(&srv->cli, path, &mode, NULL, NULL)) {
+ errno = smbw_errno(&srv->cli);
+ goto failed;
+ }
+
+ /* assume success */
+
+ smbw_busy--;
+ return 0;
+
+ failed:
+ smbw_busy--;
+ return -1;
+}
+
+/*****************************************************
+a wrapper for chmod()
+*******************************************************/
+int smbw_chmod(const char *fname, mode_t newmode)
+{
+ struct smbw_server *srv;
+ fstring server, share;
+ pstring path;
+ uint32 mode;
+
+ DEBUG(4,("%s (%s)\n", __FUNCTION__, fname));
+
+ if (!fname) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ smbw_init();
+
+ smbw_busy++;
+
+ /* work out what server they are after */
+ smbw_parse_path(fname, server, share, path);
+
+ /* get a connection to the server */
+ srv = smbw_server(server, share);
+ if (!srv) {
+ /* smbw_server sets errno */
+ goto failed;
+ }
+
+ if (!cli_getatr(&srv->cli, path, &mode, NULL, NULL)) {
+ errno = smbw_errno(&srv->cli);
+ goto failed;
+ }
+
+ /* assume success for the moment - need to add attribute mapping */
+
+ smbw_busy--;
+ return 0;
+
+ failed:
+ smbw_busy--;
+ return -1;
+}
--- /dev/null
+/*
+ Unix SMB/Netbios implementation.
+ Version 2.0
+ SMB wrapper functions
+ Copyright (C) Andrew Tridgell 1998
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "wrapper.h"
+
+ int utime(const char *name,struct timeval *tvp)
+{
+ if (smbw_path(name)) {
+ return smbw_utime(name, tvp);
+ }
+
+ return real_utime(name, tvp);
+}