-/*
+/*
Unix SMB/CIFS implementation.
functions to calculate the free disk space
Copyright (C) Andrew Tridgell 1998-2000
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "replace.h"
#include "lib/util/samba_util.h"
#include "system/filesys.h"
-
+
/**
* @file
* @brief Utility functions for getting the amount of free disk space
* Retrieve amount of free disk space.
* this does all of the system specific guff to get the free disk space.
* It is derived from code in the GNU fileutils package, but has been
- * considerably mangled for use here
+ * considerably mangled for use here
*
* results are returned in *dfree and *dsize, in 512 byte units
*/
if (statfs (path, &fsd, sizeof (struct statfs)) != 0)
return -1;
#endif /* STAT_STATFS3_OSF1 */
-
+
#ifdef STAT_STATFS2_FS_DATA /* Ultrix */
-#define CONVERT_BLOCKS(B) adjust_blocks ((uint64_t)(B), (uint64_t)1024, (uint64_t)512)
+#define CONVERT_BLOCKS(B) adjust_blocks ((uint64_t)(B), (uint64_t)1024, (uint64_t)512)
struct fs_data fsd;
-
+
if (statfs (path, &fsd) != 1)
return -1;
-
+
(*dsize) = CONVERT_BLOCKS (fsd.fd_req.btot);
(*dfree) = CONVERT_BLOCKS (fsd.fd_req.bfreen);
#endif /* STAT_STATFS2_FS_DATA */
-
+
#ifdef STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */
#define CONVERT_BLOCKS(B) adjust_blocks ((uint64_t)(B), (uint64_t)fsd.f_bsize, (uint64_t)512)
struct statfs fsd;
-
+
if (statfs (path, &fsd) < 0)
return -1;
-
+
#ifdef STATFS_TRUNCATES_BLOCK_COUNTS
/* In SunOS 4.1.2, 4.1.3, and 4.1.3_U1, the block counts in the
struct statfs are truncated to 2GB. These conditions detect that
}
#endif /* STATFS_TRUNCATES_BLOCK_COUNTS */
#endif /* STAT_STATFS2_BSIZE */
-
+
#ifdef STAT_STATFS2_FSIZE /* 4.4BSD */
#define CONVERT_BLOCKS(B) adjust_blocks ((uint64_t)(B), (uint64_t)fsd.f_fsize, (uint64_t)512)
-
+
struct statfs fsd;
-
+
if (statfs (path, &fsd) < 0)
return -1;
#endif /* STAT_STATFS2_FSIZE */
-
+
#ifdef STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */
# if _AIX || defined(_CRAY)
# define CONVERT_BLOCKS(B) adjust_blocks ((uint64_t)(B), (uint64_t)fsd.f_bsize, (uint64_t)512)
# endif
# endif
# endif
-
+
struct statfs fsd;
if (statfs (path, &fsd, sizeof fsd, 0) < 0)
-/*
+/*
Unix SMB/CIFS implementation.
FAKE FILE support, for faking up special files windows want access to
Copyright (C) Stefan (metze) Metzmacher 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
-/*
+/*
Unix SMB/CIFS implementation.
SMB parameters and setup, plus a whole lot more.
-
+
Copyright (C) Andrew Tridgell 1992-2000
Copyright (C) John H Terpstra 1996-2002
Copyright (C) Luke Kenneth Casson Leighton 1996-2000
Copyright (C) Paul Ashton 1998-2000
Copyright (C) Simo Sorce 2001-2002
Copyright (C) Martin Pool 2002
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/* the desired access to use when opening a pipe */
#define DESIRED_ACCESS_PIPE 0x2019f
-
+
/* Mapping of access rights to UNIX perms. */
#define UNIX_ACCESS_RWX FILE_GENERIC_ALL
#define UNIX_ACCESS_R FILE_GENERIC_READ
* it to 6.1 to mimic Win2K8R2.
*
*/
-
+
#define SAMBA_MAJOR_NBT_ANNOUNCE_VERSION 0x06
#define SAMBA_MINOR_NBT_ANNOUNCE_VERSION 0x01
-/*
+/*
Unix SMB/CIFS implementation.
Portable SMB ACL interface
Copyright (C) Jeremy Allison 2000
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
*/
saved_handler = CatchChildLeaveStatus();
-
+
if ((pid=fork()) < 0) {
DEBUG(0,("smbrun: fork failed with error %s\n", strerror(errno) ));
(void)CatchSignal(SIGCLD, saved_handler);
int status=0;
pid_t wpid;
-
+
/* the parent just waits for the child to exit */
while((wpid = waitpid(pid,&status,0)) < 0) {
if(errno == EINTR) {
return status;
}
-
+
(void)CatchChild();
-
+
/* we are in the child. we exec /bin/sh to do the work for us. we
don't directly exec the command we want because it may be a
pipeline or anything else the config file specifies */
-
+
/* point our stdout at the file we want output to go into */
if (outfd) {
close(1);
SAFE_FREE(newcmd);
}
-
+
/* not reached */
exit(83);
return 1;
gid_t gid = current_user.ut.gid;
int ifd[2];
void (*saved_handler)(int);
-
+
/*
* Lose any elevated privileges.
*/
*/
saved_handler = CatchChildLeaveStatus();
-
+
if ((pid=fork()) < 0) {
DEBUG(0, ("smbrunsecret: fork failed with error %s\n", strerror(errno)));
(void)CatchSignal(SIGCLD, saved_handler);
pid_t wpid;
size_t towrite;
ssize_t wrote;
-
+
close(ifd[0]);
/* send the secret */
towrite = strlen(secret);
return status;
}
-
+
(void)CatchChild();
-
+
/* we are in the child. we exec /bin/sh to do the work for us. we
don't directly exec the command we want because it may be a
pipeline or anything else the config file specifies */
-
+
close(ifd[1]);
close(0);
if (dup2(ifd[0], 0) != 0) {
2 point to /dev/null from the startup code */
closefrom(3);
- execl("/bin/sh", "sh", "-c", cmd, NULL);
+ execl("/bin/sh", "sh", "-c", cmd, NULL);
/* not reached */
exit(82);
}
/****************************************************************************
- Gain root privilege before doing something.
+ Gain root privilege before doing something.
We want to end up with ruid==euid==0
****************************************************************************/
void gain_root_privilege(void)
-{
+{
#if defined(USE_SETRESUID) || defined(HAVE_LINUX_THREAD_CREDENTIALS)
samba_setresuid(0,0,0);
#endif
-
+
#if USE_SETEUID
samba_seteuid(0);
#endif
/****************************************************************************
Set effective uid, and possibly the real uid too.
We want to end up with either:
-
+
ruid==uid and euid==uid
or
}
/****************************************************************************
- save the real and effective gid for later restoration. Used by the
+ save the real and effective gid for later restoration. Used by the
getgroups code
****************************************************************************/
void save_re_gid(void)
samba_setuidx(ID_EFFECTIVE, uid);
samba_setuid(uid);
#endif
-
+
assert_uid(uid, uid);
assert_gid(gid, gid);
}
exit(1);
#endif
- /* if not running as root then at least check to see if we get ENOSYS - this
+ /* if not running as root then at least check to see if we get ENOSYS - this
handles Linux 2.0.x with glibc 2.1 */
fprintf(stderr,"not running as root: checking for ENOSYS\n");
exit(have_syscall());
/****************************************************************************
Check if we are setuid root. Used in libsmb and smbpasswd paranoia checks.
****************************************************************************/
-bool is_setuid_root(void)
+bool is_setuid_root(void)
{
return (geteuid() == (uid_t)0) && (getuid() != (uid_t)0);
}
-/*
+/*
Unix SMB/CIFS implementation.
VFS API's statvfs abstraction
Copyright (C) Alexander Bokovoy 2005
Copyright (C) Steve French 2005
Copyright (C) James Peach 2006
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
}
#endif
-/*
+/*
sys_statvfs() is an abstraction layer over system-dependent statvfs()/statfs()
for particular POSIX systems. Due to controversy of what is considered more important
between LSB and FreeBSD/POSIX.1 (IEEE Std 1003.1-2001) we need to abstract the interface
-/*
+/*
Unix SMB/CIFS implementation.
- SMB2 client calls
+ SMB2 client calls
Copyright (C) Andrew Tridgell 2005
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
struct smb2_negprot {
struct {
uint16_t dialect_count; /* size of dialects array */
- uint16_t security_mode; /* 0==signing disabled
+ uint16_t security_mode; /* 0==signing disabled
1==signing enabled */
uint16_t reserved;
uint32_t capabilities;