Bug 7470 - Improper use of S_IREAD and S_IWRITE
Improper use of S_IREAD and S_IWRITE
Status: RESOLVED FIXED
Product: Samba 3.5
Classification: Unclassified
Component: Build environment
3.5.3
Other Other
: P3 normal
: ---
Assigned To: Karolin Seeger
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-05-28 02:24 UTC by Joachim Schmitz
Modified: 2010-10-06 14:05 UTC (History)
0 users

See Also:


Attachments
Patch (1.85 KB, patch)
2010-06-01 04:14 UTC, Joachim Schmitz
no flags Details
Patch for 3.5 (2.21 KB, patch)
2010-09-25 13:08 UTC, Volker Lendecke
obnox: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joachim Schmitz 2010-05-28 02:24:31 UTC
Rather than using S_IRREAD and S_IWRITE in .../source3/registry/reg_api.c
, .../source3/registry/reg_api.c and .../source3/registry/reg_api.c, the standard S_IRUSR and S_IWUSR should get used, if available. Patch:

diff -u ./source3/modules/vfs_scannedonly.c.orig ./source3/modules/vfs_scannedonly.c
--- ./source3/modules/vfs_scannedonly.c.orig	2010-05-17 06:51:23.000000000 -0500
+++ ./source3/modules/vfs_scannedonly.c	2010-05-26 15:21:40.000000000 -0500
@@ -476,7 +476,9 @@
 			       "(max %d), %d ms) for %s\n",
 			       i, recheck_tries,
 			       recheck_time, cache_smb_fname->base_name));
+#ifdef HAVE_NANOSLEEP /* ??? */
 			nanosleep(&req, NULL);
+#endif
 			retval = SMB_VFS_NEXT_STAT(handle, cache_smb_fname);
 			i++;
 		}
diff -u ./source3/registry/reg_api.c.orig ./source3/registry/reg_api.c
--- ./source3/registry/reg_api.c.orig	2010-05-17 06:51:23.000000000 -0500
+++ ./source3/registry/reg_api.c	2010-05-26 14:36:46.000000000 -0500
@@ -953,7 +953,11 @@
 	/* open the registry file....fail if the file already exists */
 
 	regfile = regfio_open(fname, (O_RDWR|O_CREAT|O_EXCL),
+#if defined(S_IRUSR) && defined(S_IWUSR)
+			      (S_IRUSR|S_IWUSR));
+#else
 			      (S_IREAD|S_IWRITE));
+#endif
 	if (regfile == NULL) {
 		DEBUG(0,("backup_registry_key: failed to open \"%s\" (%s)\n",
 			 fname, strerror(errno) ));
diff -u ./source3/utils/net_rpc_registry.c.orig ./source3/utils/net_rpc_registry.c
--- ./source3/utils/net_rpc_registry.c.orig	2010-05-17 06:51:23.000000000 -0500
+++ ./source3/utils/net_rpc_registry.c	2010-05-26 09:13:51.000000000 -0500
@@ -1150,7 +1150,11 @@
 	d_printf(_("ok\n"));
 
 	d_printf(_("Opening %s...."), argv[1]);
+#if defined(S_IRUSR) && defined(S_IWUSR)
+	if ( !(outfile = regfio_open( argv[1], (O_RDWR|O_CREAT|O_TRUNC), (S_IRUSR|S_IWUSR) )) ) {
+#else
 	if ( !(outfile = regfio_open( argv[1], (O_RDWR|O_CREAT|O_TRUNC), (S_IREAD|S_IWRITE) )) ) {
+#endif
 		d_fprintf(stderr, _("Failed to open %s for writing\n"),argv[1]);
 		goto out;
 	}
diff -u ./source3/utils/profiles.c.orig ./source3/utils/profiles.c
--- ./source3/utils/profiles.c.orig	2010-05-17 06:51:23.000000000 -0500
+++ ./source3/utils/profiles.c	2010-05-26 09:16:24.000000000 -0500
@@ -275,7 +275,11 @@
 		exit (1);
 	}
 
+#if defined(S_IRUSR) && defined(S_IWUSR)
+	if ( !(outfile = regfio_open( new_filename, (O_RDWR|O_CREAT|O_TRUNC), (S_IRUSR|S_IWUSR) )) ) {
+#else
 	if ( !(outfile = regfio_open( new_filename, (O_RDWR|O_CREAT|O_TRUNC), (S_IREAD|S_IWRITE) )) ) {
+#endif
 		fprintf( stderr, "Failed to open new file %s!\n", new_filename );
 		fprintf( stderr, "Error was (%s)\n", strerror(errno) );
 		exit (1);


Bye, Jojo
Comment 1 Joachim Schmitz 2010-05-28 02:44:56 UTC
See also the very old and long closed bug #546
Comment 2 Joachim Schmitz 2010-05-30 14:50:54 UTC
oops, forget the 1st patch, that one is for bug #7478.
And another way to fix it might to to #define S_IREAD and S_IWRITE (to S_IRUSR and S_IWUSR respectively) in .../lib/replace/replace.h?

Bye, Jojo
Comment 3 Joachim Schmitz 2010-06-01 04:14:53 UTC
Created attachment 5754 [details]
Patch
Comment 4 Joachim Schmitz 2010-09-25 09:23:52 UTC
From http://www.gnu.org/s/libc/manual/html_node/Permission-Bits.html:

S_IRUSR
S_IREAD
Read permission bit for the owner of the file. On many systems this bit is 0400. S_IREAD is an obsolete synonym provided for BSD compatibility. 

S_IWUSR
S_IWRITE
Write permission bit for the owner of the file. Usually 0200. S_IWRITE is an obsolete synonym provided for BSD compatibility. 

S_IXUSR
S_IEXEC
Execute (for ordinary files) or search (for directories) permission bit for the owner of the file. Usually 0100. S_IEXEC is an obsolete synonym provided for BSD compatibility. 

Bye, Jojo
Comment 5 Volker Lendecke 2010-09-25 13:08:07 UTC
Created attachment 5983 [details]
Patch for 3.5

No need to #ifdef that. We use S_IRUSR|S_IWUSR elsewhere unconditionally.

Volker
Comment 6 Joachim Schmitz 2010-09-25 16:48:49 UTC
Well, that certainly works too ;-)
Comment 7 Michael Adam 2010-09-27 05:12:22 UTC
Comment on attachment 5983 [details]
Patch for 3.5

thanks for spotting and fixing
Comment 8 Michael Adam 2010-09-29 02:24:41 UTC
Assiging to Karolin for picking to release.
Comment 9 Karolin Seeger 2010-10-06 14:05:32 UTC
Pushed to v3-5-test.
Closing out bug report.

Thanks!