Discussion:
about default file permission of SQLite database file
Shan, Zhe (Jay)
2007-02-22 03:20:18 UTC
Permalink
Hi,

If to use SQLite to create a database in Linux, the database file will
be granted permission 644 as default.
Is this value hardcoded in the current version? Is it possible to
change this default vaule, say to 664 or something else?


Thanks.

Jay
miguel manese
2007-02-22 03:45:33 UTC
Permalink
This is not actually about SQLite. man umask

M. Manese
Post by Shan, Zhe (Jay)
Hi,
If to use SQLite to create a database in Linux, the database file will
be granted permission 644 as default.
Is this value hardcoded in the current version? Is it possible to
change this default vaule, say to 664 or something else?
Thanks.
Jay
-----------------------------------------------------------------------------
To unsubscribe, send email to sqlite-users-unsubscribe-CzDROfG0BjIdnm+***@public.gmane.org
-----------------------------------------------------------------------------
Joe Wilson
2007-02-22 03:51:03 UTC
Permalink
Post by Shan, Zhe (Jay)
If to use SQLite to create a database in Linux, the database file will
be granted permission 644 as default.
Is this value hardcoded in the current version? Is it possible to
change this default vaule, say to 664 or something else?
man umask




____________________________________________________________________________________
Cheap talk?
Check out Yahoo! Messenger's low PC-to-Phone call rates.
http://voice.yahoo.com

-----------------------------------------------------------------------------
To unsubscribe, send email to sqlite-users-unsubscribe-CzDROfG0BjIdnm+***@public.gmane.org
-----------------------------------------------------------------------------
Shan, Zhe (Jay)
2007-02-22 14:42:35 UTC
Permalink
I've tried umask, but it does not work for SQLite.

I search this emaillist, and find the following message in 2003 which is
related to this topic. I want to check if it is still true in the current
version. Thanks.

Jay
From: Dong Xuezhang-A19583
Subject: SQLITE MODE<http://news.gmane.org/find-root.php?message_id=%3c5725AF6EE9FAD51195DC009027E377020B9B6901%40az33exm35.corp.mot.com%3e>
Newsgroups: gmane.comp.db.sqlite.general<http://news.gmane.org/gmane.comp.db.sqlite.general>
Date: 2003-09-30 18:30:11 GMT (3 years, 20 weeks, 4 days, 14 hours and 24
minutes ago)
Hi,
Just want to buy some idea from you guys about the *permission* of
sqlite db *file*. It is hardcode to 644 right
now(user RW, group and other person R). In certain case, like group
developing or ..., you may want 664 or
even 666. There are two way to do this, one is make it become a
compilation option, another one is the pass in a
parameter from sqlite_open method. I notice that there is a parameter
(int mode) in sqlite_open never
been used, is it a good idea to use it for this purpose?
Thanks.
Xuezhang.
Post by Shan, Zhe (Jay)
If to use SQLite to create a database in Linux, the database file will
be granted permission 644 as default.
Is this value hardcoded in the current version? Is it possible to
change this default vaule, say to 664 or something else?
man umask
____________________________________________________________________________________
Cheap talk?
Check out Yahoo! Messenger's low PC-to-Phone call rates.
http://voice.yahoo.com
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Joe Wilson
2007-02-23 14:21:50 UTC
Permalink
Post by Shan, Zhe (Jay)
I've tried umask, but it does not work for SQLite.
Here are the default permissions used with open()'s O_CREAT flag:

src/os_os2.h:# define SQLITE_DEFAULT_FILE_PERMISSIONS 0600
src/os_unix.c:# define SQLITE_DEFAULT_FILE_PERMISSIONS 0644

But umask still plays a role in this (I can never remember the umask
number's effect without experimentation).

man open:

SYNOPSIS

#include <fcntl.h>

int open(const char *path, int flags, mode_t mode);

DESCRIPTION

The file name specified by path is opened for reading and/or
writing as specified by the argument flags and the file descriptor
returned to the calling process. The flags argument may indicate
the file is to be created if it does not exist (by specifying the
O_CREAT flag), in which case the file is created with mode mode as
described in chmod(2) and modified by the process' umask value (see
umask(2)).

Another option is to create a zero-length sqlite database file yourself
through other means (touch, chmod, etc) before you call sqlite3_open().



____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com

-----------------------------------------------------------------------------
To unsubscribe, send email to sqlite-users-unsubscribe-CzDROfG0BjIdnm+***@public.gmane.org
-----------------------------------------------------------------------------
Martin Jenkins
2007-02-23 15:21:24 UTC
Permalink
I can never remember the umask number's effect without
experimentation
DESCRIPTION
umask sets the umask to mask & 0777.

The umask is used by open(2) to set initial file permissions on a
newly-created file. Specifically, permissions in the umask are turned
off from the mode argument to open(2) (so, for example, the common umask
default value of 022 results in new files being created with permissions
0666 & ~022 = 0644 = rw-r--r-- in the usual case where the mode is
specified as 0666).

Martin

-----------------------------------------------------------------------------
To unsubscribe, send email to sqlite-users-unsubscribe-CzDROfG0BjIdnm+***@public.gmane.org
-----------------------------------------------------------------------------
John Stanton
2007-02-23 15:21:09 UTC
Permalink
It would be better to make the create permission 0666. Then umask can
restrict that permission and the user can get whatever permission
required by the application.
Post by Joe Wilson
Post by Shan, Zhe (Jay)
I've tried umask, but it does not work for SQLite.
src/os_os2.h:# define SQLITE_DEFAULT_FILE_PERMISSIONS 0600
src/os_unix.c:# define SQLITE_DEFAULT_FILE_PERMISSIONS 0644
But umask still plays a role in this (I can never remember the umask
number's effect without experimentation).
SYNOPSIS
#include <fcntl.h>
int open(const char *path, int flags, mode_t mode);
DESCRIPTION
The file name specified by path is opened for reading and/or
writing as specified by the argument flags and the file descriptor
returned to the calling process. The flags argument may indicate
the file is to be created if it does not exist (by specifying the
O_CREAT flag), in which case the file is created with mode mode as
described in chmod(2) and modified by the process' umask value (see
umask(2)).
Another option is to create a zero-length sqlite database file yourself
through other means (touch, chmod, etc) before you call sqlite3_open().
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
To unsubscribe, send email to sqlite-users-unsubscribe-CzDROfG0BjIdnm+***@public.gmane.org
-----------------------------------------------------------------------------
Loading...