diff options
Diffstat (limited to 'source3/locking')
-rw-r--r-- | source3/locking/locking_slow.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source3/locking/locking_slow.c b/source3/locking/locking_slow.c index de2bb1701c..d6ac6efac1 100644 --- a/source3/locking/locking_slow.c +++ b/source3/locking/locking_slow.c @@ -502,8 +502,17 @@ mode file %s (%s)\n", fname, strerror(errno))); return 0; } /* Now truncate the file at this point. */ +#ifdef FTRUNCATE_NEEDS_ROOT + become_root(False); +#endif /* FTRUNCATE_NEEDS_ROOT */ + if(ftruncate(fd, newsize)!= 0) { + +#ifdef FTRUNCATE_NEEDS_ROOT + unbecome_root(False); +#endif /* FTRUNCATE_NEEDS_ROOT */ + DEBUG(0,("ERROR: get_share_modes: failed to ftruncate share \ mode file %s to size %d (%s)\n", fname, newsize, strerror(errno))); if(*old_shares) @@ -515,6 +524,10 @@ mode file %s to size %d (%s)\n", fname, newsize, strerror(errno))); } } +#ifdef FTRUNCATE_NEEDS_ROOT + unbecome_root(False); +#endif /* FTRUNCATE_NEEDS_ROOT */ + if(buf) free(buf); @@ -653,15 +666,29 @@ mode file %s (%s)\n", fname, strerror(errno))); free(buf); return; } + /* Now truncate the file at this point. */ +#ifdef FTRUNCATE_NEEDS_ROOT + become_root(False); +#endif /* FTRUNCATE_NEEDS_ROOT */ + if(ftruncate(fd, newsize) != 0) { + +#ifdef FTRUNCATE_NEEDS_ROOT + unbecome_root(False); +#endif /* FTRUNCATE_NEEDS_ROOT */ + DEBUG(0,("ERROR: del_share_mode: failed to ftruncate share \ mode file %s to size %d (%s)\n", fname, newsize, strerror(errno))); if(buf) free(buf); return; } + +#ifdef FTRUNCATE_NEEDS_ROOT + unbecome_root(False); +#endif /* FTRUNCATE_NEEDS_ROOT */ } /******************************************************************* @@ -795,8 +822,18 @@ deleting it (%s).\n",fname, strerror(errno))); } /* Now truncate the file at this point - just for safety. */ + +#ifdef FTRUNCATE_NEEDS_ROOT + become_root(False); +#endif /* FTRUNCATE_NEEDS_ROOT */ + if(ftruncate(fd, header_size + (SMF_ENTRY_LENGTH*num_entries))!= 0) { + +#ifdef FTRUNCATE_NEEDS_ROOT + unbecome_root(False); +#endif /* FTRUNCATE_NEEDS_ROOT */ + DEBUG(0,("ERROR: set_share_mode: failed to ftruncate share \ mode file %s to size %d (%s)\n", fname, header_size + (SMF_ENTRY_LENGTH*num_entries), strerror(errno))); @@ -805,6 +842,10 @@ mode file %s to size %d (%s)\n", fname, header_size + (SMF_ENTRY_LENGTH*num_entr return False; } +#ifdef FTRUNCATE_NEEDS_ROOT + unbecome_root(False); +#endif /* FTRUNCATE_NEEDS_ROOT */ + if(buf) free(buf); |