LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-13-2004, 07:07 PM   #1
jon_k
Member
 
Registered: Jul 2003
Location: Fort Worth, Texas
Distribution: Mepis Linux 2004
Posts: 547

Rep: Reputation: 30
Isolating read access to only to one file only by another file.


I'd like to be able to set up a server application that can only READ a certain file. Say a user owns a file called "server", I don't want the user to be able to gain access to the file "huh" but I wan't the server (which is under that persons username) to be able to access it.

Is this possible? And most importantly which way would I do this?

Regards,

Last edited by jon_k; 08-13-2004 at 07:09 PM.
 
Old 08-13-2004, 09:21 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If the file owner doesn't have read access for the owner (u) permission bit, then the file can't be read even if the group access allows it. You may want to test this. I read it in a 'Programming by Example' book.

I'm not sure that I understood the question. You want write only access to a certain directory for a user, to create a file that a server of some type uses?

Or perhaps you are thinking more of writing to a named pipe that the server has exclusive read access to?

Last edited by jschiwal; 08-13-2004 at 09:23 PM.
 
Old 08-13-2004, 10:12 PM   #3
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
here is an example of the locking mechanism
Code:
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main (int argc, char* argv[])
{
  char* file = argv[1];
  int fd;
  struct flock lock;

  printf ("opening %s\n", file);
  /* Open a file descriptor to the file.  */
  fd = open (file, O_WRONLY);
  printf ("locking\n");
  /* Initialize the flock structure.  */
  memset (&lock, 0, sizeof(lock));
  lock.l_type = F_WRLCK;
  /* Place a write lock on the file.  */
  fcntl (fd, F_SETLKW, &lock);

  printf ("locked; hit enter to unlock... ");
  /* Wait for the user to hit enter.  */
  getchar ();

  printf ("unlocking\n");
  /* Release the lock.  */
  lock.l_type = F_UNLCK;
  fcntl (fd, F_SETLKW, &lock);

  close (fd);
  return 0;
}
 
Old 08-14-2004, 05:16 AM   #4
jon_k
Member
 
Registered: Jul 2003
Location: Fort Worth, Texas
Distribution: Mepis Linux 2004
Posts: 547

Original Poster
Rep: Reputation: 30
Well... let me break it down in to this:

We have an account called john doe.
We also have an account called joe-sixpack

John doe has a server binary in /home/jondoe/server/bin/serverbinary
Joe sixpack has a server binary in /home/joesix/server/bin/serverbinary

Server binary has a config file that it loads located in /home/<user>/server/bin/config.conf

This config file loads plugins in a "centralized location" so we don't have to have such plugins/config files in each users account.

Server config file looks something like
loadplugin /home/shared/pluginbin/plugin.so /home/shared/plug-conf/plugin.conf
loadplugin /home/shared/pluginbin/plugin2.so /home/shared/plug-conf/plugin2.config

We want joesixpack and jon doe to:
Be able to:
Run the serverbinary under their own account name (and of course, the serverbinary needs access privilages to read the plugin and plugin config (but NOT to write))
To [b]NOT[b] be able to:
Give the user jondoe or joesixpack the ability to grab the the plugins or configuration for such from our '/home/shared' directory.

In otherwords we want the serverbinary who resides and executes under each user to be able to read plugins and configs

However we DON'T want the user itself to be able to read (download or view) the plugin it's config


So... in other words... have the serverbinary have read access to a file ---- have the user itself not have read-access
(Yet have the binary run under the users name)

So... in other words -- giving one indvidual file read-access to another file... rather than giving the entire user read-access

Is this impossible for this current setup we have?

Last edited by jon_k; 08-14-2004 at 05:19 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Read parameters from config file (file parser?) alaios Programming 8 07-09-2012 11:29 AM
How to read .chm file in fedora, can't mount ntfs file system ishti_du Linux - Newbie 12 03-06-2007 03:27 AM
read/write in *.MDB (MS-Access file) form Linux FC3 thuan1975 Linux - Software 1 08-11-2005 01:25 AM
which is the best file system for read write access from linux and windows tomank Linux - Newbie 4 04-05-2004 08:48 AM
need multiple users to have read/write access to a Quickbooks file at the same time. rbelknap Linux - Security 2 10-14-2003 10:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration