[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Thu Feb 26 10:29:03 MST 2015
The branch, master has been updated
via 1237b00 lib: Simplify pidfile.c
via bd6bc30 Fix whitespace
from 079c301 ntdb: always return int from tdb_store_flag_to_ntdb()
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 1237b006d5fad9523fb7e7bf9ecb09df66afb7f6
Author: Volker Lendecke <vl at samba.org>
Date: Mon Jan 19 10:52:11 2015 +0100
lib: Simplify pidfile.c
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Volker Lendecke <vl at samba.org>
Autobuild-Date(master): Thu Feb 26 18:28:31 CET 2015 on sn-devel-104
commit bd6bc30693ce989588d8ebebeb717f4e82d590c4
Author: Volker Lendecke <vl at samba.org>
Date: Wed Jan 14 17:11:12 2015 +0100
Fix whitespace
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/util/pidfile.c | 41 +++++++++++++++++------------------------
libcli/security/display_sec.c | 14 +++++++-------
librpc/idl/smb_acl.idl | 20 ++++++++++----------
3 files changed, 34 insertions(+), 41 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/util/pidfile.c b/lib/util/pidfile.c
index 1b382d1..5590780 100644
--- a/lib/util/pidfile.c
+++ b/lib/util/pidfile.c
@@ -1,20 +1,20 @@
/* this code is broken - there is a race condition with the unlink (tridge) */
-/*
+/*
Unix SMB/CIFS implementation.
pidfile handling
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 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/>.
*/
@@ -30,23 +30,21 @@
/**
* return the pid in a pidfile. return 0 if the process (or pidfile)
- * does not exist
+ * does not exist
*/
pid_t pidfile_pid(const char *piddir, const char *name)
{
+ size_t len = strlen(piddir) + strlen(name) + 6;
+ char pidFile[len];
int fd;
char pidstr[20];
pid_t ret = -1;
- char *pidFile;
- if (asprintf(&pidFile, "%s/%s.pid", piddir, name) < 0) {
- return 0;
- }
+ snprintf(pidFile, sizeof(pidFile), "%s/%s.pid", piddir, name);
fd = open(pidFile, O_NONBLOCK | O_RDONLY, 0644);
if (fd == -1) {
- SAFE_FREE(pidFile);
return 0;
}
@@ -62,7 +60,7 @@ pid_t pidfile_pid(const char *piddir, const char *name)
pidFile));
goto noproc;
}
-
+
if (!process_exists_by_pid(ret)) {
DEBUG(10, ("Process with PID=%d does not exist.\n", (int)ret));
goto noproc;
@@ -76,7 +74,6 @@ pid_t pidfile_pid(const char *piddir, const char *name)
}
close(fd);
- SAFE_FREE(pidFile);
DEBUG(10, ("Process with PID=%d is running.\n", (int)ret));
return ret;
@@ -85,35 +82,32 @@ pid_t pidfile_pid(const char *piddir, const char *name)
DEBUG(10, ("Deleting %s, since %d is not a Samba process.\n", pidFile,
(int)ret));
unlink(pidFile);
- SAFE_FREE(pidFile);
return 0;
}
/**
- * create a pid file in the pid directory. open it and leave it locked
+ * create a pid file in the pid directory. open it and leave it locked
*/
void pidfile_create(const char *piddir, const char *name)
{
+ size_t len = strlen(piddir) + strlen(name) + 6;
+ char pidFile[len];
int fd;
char buf[20];
- char *pidFile;
pid_t pid;
- if (asprintf(&pidFile, "%s/%s.pid", piddir, name) < 0) {
- DEBUG(0,("ERROR: Out of memory\n"));
- exit(1);
- }
+ snprintf(pidFile, sizeof(pidFile), "%s/%s.pid", piddir, name);
pid = pidfile_pid(piddir, name);
if (pid != 0) {
- DEBUG(0,("ERROR: %s is already running. File %s exists and process id %d is running.\n",
+ DEBUG(0,("ERROR: %s is already running. File %s exists and process id %d is running.\n",
name, pidFile, (int)pid));
exit(1);
}
fd = open(pidFile, O_NONBLOCK | O_CREAT | O_WRONLY | O_EXCL, 0644);
if (fd == -1) {
- DEBUG(0,("ERROR: can't open %s: Error was %s\n", pidFile,
+ DEBUG(0,("ERROR: can't open %s: Error was %s\n", pidFile,
strerror(errno)));
exit(1);
}
@@ -121,7 +115,7 @@ void pidfile_create(const char *piddir, const char *name)
smb_set_close_on_exec(fd);
if (fcntl_lock(fd,F_SETLK,0,1,F_WRLCK)==false) {
- DEBUG(0,("ERROR: %s : fcntl lock of file %s failed. Error was %s\n",
+ DEBUG(0,("ERROR: %s : fcntl lock of file %s failed. Error was %s\n",
name, pidFile, strerror(errno)));
exit(1);
}
@@ -129,13 +123,12 @@ void pidfile_create(const char *piddir, const char *name)
memset(buf, 0, sizeof(buf));
slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int) getpid());
if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) {
- DEBUG(0,("ERROR: can't write to file %s: %s\n",
+ DEBUG(0,("ERROR: can't write to file %s: %s\n",
pidFile, strerror(errno)));
exit(1);
}
/* Leave pid file open & locked for the duration... */
- SAFE_FREE(pidFile);
}
void pidfile_unlink(const char *piddir, const char *name)
diff --git a/libcli/security/display_sec.c b/libcli/security/display_sec.c
index de8bb8b..a8d173c 100644
--- a/libcli/security/display_sec.c
+++ b/libcli/security/display_sec.c
@@ -1,19 +1,19 @@
-/*
+/*
Unix SMB/CIFS implementation.
Samba utility functions
Copyright (C) Andrew Tridgell 1992-1999
Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
-
+
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,
+
+ 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/>.
*/
@@ -237,7 +237,7 @@ void display_sec_acl(struct security_acl *sec_acl)
uint32_t i;
printf("\tACL\tNum ACEs:\t%u\trevision:\t%x\n",
- sec_acl->num_aces, sec_acl->revision);
+ sec_acl->num_aces, sec_acl->revision);
printf("\t---\n");
if (sec_acl->size != 0 && sec_acl->num_aces != 0) {
@@ -283,7 +283,7 @@ void display_acl_type(uint16_t type)
printf("SEC_DESC_RM_CONTROL_VALID ");
if (type & SEC_DESC_SELF_RELATIVE) /* 0x8000 */
printf("SEC_DESC_SELF_RELATIVE ");
-
+
printf("\n");
}
diff --git a/librpc/idl/smb_acl.idl b/librpc/idl/smb_acl.idl
index ffd1ee2..a7a76c9 100644
--- a/librpc/idl/smb_acl.idl
+++ b/librpc/idl/smb_acl.idl
@@ -1,28 +1,28 @@
-/*
+/*
Unix SMB/CIFS implementation.
Portable SMB ACL interface
Copyright (C) Jeremy Allison 2000
Copyright (C) Andrew Bartlett 2012
-
+
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/>.
*/
-/*
+/*
* Allow the smb_acl interface to be pushed into an NDR blob and
* read/written in python.
- *
+ *
* The exact layout of these stuctures is CRITICAL, as a SHA-256 hash is
* taken over these after they are pushed as NDR blobs, and stored in an
* xattr for ACL verification.
@@ -62,7 +62,7 @@ interface smb_acl
[case (SMB_ACL_GROUP)] smb_acl_group group;
[case (SMB_ACL_GROUP_OBJ)];
[case (SMB_ACL_OTHER)];
- [case (SMB_ACL_MASK)];
+ [case (SMB_ACL_MASK)];
} smb_acl_entry_info;
typedef struct {
@@ -70,16 +70,16 @@ interface smb_acl
[switch_is(a_type)] smb_acl_entry_info info;
mode_t a_perm;
} smb_acl_entry;
-
+
[public] typedef struct {
int count;
[value(0)] int next;
[size_is(count)] smb_acl_entry acl[*];
} smb_acl_t;
-
+
const int SMB_ACL_FIRST_ENTRY = 0;
const int SMB_ACL_NEXT_ENTRY = 1;
-
+
const int SMB_ACL_TYPE_ACCESS = 0;
const int SMB_ACL_TYPE_DEFAULT = 1;
--
Samba Shared Repository
More information about the samba-cvs
mailing list