summaryrefslogtreecommitdiffstats
path: root/source/lib
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1998-12-01 16:04:24 +0000
committerLuke Leighton <lkcl@samba.org>1998-12-01 16:04:24 +0000
commit51c1c31768a92d9c57ee6c09b78419bcbc544f03 (patch)
tree75ecbed15597b8158b5397dd46a7294699b6cd9f /source/lib
parent474f94f419a531e33b475249da7efb99ac22f454 (diff)
downloadsamba-51c1c31768a92d9c57ee6c09b78419bcbc544f03.tar.gz
samba-51c1c31768a92d9c57ee6c09b78419bcbc544f03.tar.xz
samba-51c1c31768a92d9c57ee6c09b78419bcbc544f03.zip
adding some samr parsing calls (group / alias adding / deleting)
added code that moves MACHINE.SID to DOMAIN_NAME.SID if it exists.
Diffstat (limited to 'source/lib')
-rw-r--r--source/lib/doscalls.c10
-rw-r--r--source/lib/sids.c20
-rw-r--r--source/lib/util.c15
3 files changed, 36 insertions, 9 deletions
diff --git a/source/lib/doscalls.c b/source/lib/doscalls.c
index 031effcf520..9cdb476d3d7 100644
--- a/source/lib/doscalls.c
+++ b/source/lib/doscalls.c
@@ -235,19 +235,11 @@ static int copy_reg(char *source, const char *dest)
int dos_rename(char *from, char *to)
{
- int rcode;
pstring zfrom, zto;
pstrcpy (zfrom, dos_to_unix (from, False));
pstrcpy (zto, dos_to_unix (to, False));
- rcode = rename (zfrom, zto);
-
- if (errno == EXDEV)
- {
- /* Rename across filesystems needed. */
- rcode = copy_reg (zfrom, zto);
- }
- return rcode;
+ return file_rename(zfrom, zto);
}
/*******************************************************************
diff --git a/source/lib/sids.c b/source/lib/sids.c
index f5fed0f656a..42f6dc68e27 100644
--- a/source/lib/sids.c
+++ b/source/lib/sids.c
@@ -277,6 +277,7 @@ BOOL generate_sam_sid(char *domain_name)
int i;
char *p;
pstring sid_file;
+ pstring machine_sid_file;
fstring sid_string;
fstring file_name;
SMB_STRUCT_STAT st;
@@ -304,10 +305,29 @@ BOOL generate_sam_sid(char *domain_name)
}
}
+ pstrcpy(machine_sid_file, sid_file);
+ pstrcat(machine_sid_file, "MACHINE.SID");
+
slprintf(file_name, sizeof(file_name)-1, "%s.SID", domain_name);
strupper(file_name);
pstrcat(sid_file, file_name);
+ if (file_exists(machine_sid_file, NULL))
+ {
+ if (file_exists(machine_sid_file, NULL))
+ {
+ DEBUG(0,("both %s and %s exist when only one should, unable to continue\n",
+ machine_sid_file, sid_file));
+ return False;
+ }
+ if (file_rename(machine_sid_file, sid_file))
+ {
+ DEBUG(0,("could not rename %s to %s. Error was %s\n",
+ machine_sid_file, sid_file, strerror(errno)));
+ return False;
+ }
+ }
+
if ((fd = sys_open(sid_file, O_RDWR | O_CREAT, 0644)) == -1) {
DEBUG(0,("unable to open or create file %s. Error was %s\n",
sid_file, strerror(errno) ));
diff --git a/source/lib/util.c b/source/lib/util.c
index 8bc75e1137e..98c840efcea 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -367,6 +367,21 @@ BOOL file_exist(char *fname,SMB_STRUCT_STAT *sbuf)
}
/*******************************************************************
+ rename a unix file
+********************************************************************/
+int file_rename(char *from, char *to)
+{
+ int rcode = rename (from, to);
+
+ if (errno == EXDEV)
+ {
+ /* Rename across filesystems needed. */
+ rcode = copy_reg (from, to);
+ }
+ return rcode;
+}
+
+/*******************************************************************
check a files mod time
********************************************************************/
time_t file_modtime(char *fname)