Recent

Author Topic: application permissions  (Read 20185 times)

mbohn

  • Full Member
  • ***
  • Posts: 120
application permissions
« on: January 09, 2010, 02:41:13 pm »
I've looked at the following in the Wiki to get some ideas on where to put the files my app needs or creates at runtime:

http://wiki.lazarus.freepascal.org/Multiplatform_Programming_Guide#Data_and_resource_files

So, I went ahead and made a directory under /usr/share and built up a tree below that directory.

Now, when my app runs it can't access files I've put there so I'm assuming I've got some sort of permissions problem.  Do I solve that programatically at run time or do I just set permissions on my directory so the application can read/write files as needed?

Bart

  • Hero Member
  • *****
  • Posts: 5702
    • Bart en Mariska's Webstek
Re: application permissions
« Reply #1 on: January 09, 2010, 02:57:39 pm »
If you need write acces to your (config) files/data, put them in a folder under $HOME (or $HOME/.config).
Files under /share or /etc are (and should be) only writeable for the root user.
You should not not change filepermissions there.
You can put static data/config there, because normally installing software requires root permissions.

Bart
(Linux newbie)

mbohn

  • Full Member
  • ***
  • Posts: 120
Re: application permissions
« Reply #2 on: January 09, 2010, 03:17:21 pm »
If you need write acces to your (config) files/data, put them in a folder under $HOME (or $HOME/.config).
Files under /share or /etc are (and should be) only writeable for the root user.
You should not not change filepermissions there.
You can put static data/config there, because normally installing software requires root permissions.

Bart
(Linux newbie)
I should have explained my app better.  It will be run by users other than myself so I don't think putting things in my home directory will work.  The other users will have permission to run the app which, in turn, will read static data files that are used by all users, and user-specific data files, then generate results and output those results by saving a file to the user's directory.

Should each user get a home directory?


alter

  • Full Member
  • ***
  • Posts: 151
    • KSP website
Re: application permissions
« Reply #4 on: January 09, 2010, 06:20:43 pm »
If you need write acces to your (config) files/data, put them in a folder under $HOME (or $HOME/.config).
Files under /share or /etc are (and should be) only writeable for the root user.
You should not not change filepermissions there.
You can put static data/config there, because normally installing software requires root permissions.

Bart
(Linux newbie)
I should have explained my app better.  It will be run by users other than myself so I don't think putting things in my home directory will work.  The other users will have permission to run the app which, in turn, will read static data files that are used by all users, and user-specific data files, then generate results and output those results by saving a file to the user's directory.

Should each user get a home directory?
Stil as Bart said you shouldn't put any config in share folder or anywhere outside home except global config that can be set only by root. However in that case you need to ensure that application is run by root or user can do su/sudo and handle this (which means reading root's password from user's input and processing it). As for home folder you can start with: Function GetUserDir : String;
So in case of global config I would read more about sudo command (yes it can be handled outside console, however I have never written something like that so I don't know details but for example in openSUSE yast works that way).

Troodon

  • Sr. Member
  • ****
  • Posts: 484
Re: application permissions
« Reply #5 on: January 10, 2010, 12:39:35 am »
I should have explained my app better.  It will be run by users other than myself so I don't think putting things in my home directory will work.  The other users will have permission to run the app which, in turn, will read static data files that are used by all users, and user-specific data files, then generate results and output those results by saving a file to the user's directory.

Should each user get a home directory?

On Linux, every user does have a home directory, usually /home/<username>. The only folders that users have R/W access to is their own home folder and the /tmp folder. All users have R access to most other folders. Therefore, if your application needs a shared folder for itself with R/W access for all users then your installation program, which must be run in superuser mode, should create such a folder, usually in /opt, and grant universal R/W to it. But that would be a bad idea; you should use a database system if you expect multiple users to access shared data in R/W mode.
Lazarus/FPC on Linux

mbohn

  • Full Member
  • ***
  • Posts: 120
Re: application permissions
« Reply #6 on: January 10, 2010, 12:46:41 am »
To be honest, I don't know exactly how the users would access the app.  But they would not be people with accounts on the computer like employees.  The app will reside on a Linux server.  Certified (via some sort of signup procedure TBD) users would submit a text case file with the inputs they want to run and the app would run with that case file.  Results would be made available as a .csv file and would either be emailed to the user or made available by download.

In the near term, for beta-testing purposes, I'll likely just have people email me a text file and I'll run it and send them the results.  Clearly, this will need to be automated at some point.

Mike J

  • Jr. Member
  • **
  • Posts: 54
  • Computer Programmer/www.NewsRx.com
    • ᏣᎳᎩ ᎦᏬᏂᎯᏍᏗ ᏗᏕᎶᏆᏍᏗ (Cherokee Language Lessons)
Re: application permissions
« Reply #7 on: January 10, 2010, 01:09:29 am »
[Option 1]
Upload via webform. (PHP) {you can ask for user id, pass and file in one step}
After upload process file and return as download. {PHP call to your program with correct args.}

[Option 2]
Upload via webform. (PHP)
After upload move file to special folder.
A separate crontab entry processes files in special folder via BASH script that then calls your program and emails the results. {look for packages uuenview and uudeview}

[Option 3]
ExtPASCAL.
You program has a direct web interface via fcgi.
ᏙᎯ

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: application permissions
« Reply #8 on: January 10, 2010, 01:27:40 am »
You should be able to do Options 1 and 2 (uploading) with Pascal using ExtPascal too.

I assume your current app has one or more forms. As a proof of concept you might try using the fmtoextp converter from the ExtP Toolkit (optional add-on for ExtPascal) to convert your forms to ExtPascal code. If you're using VCL/LCL controls that are supported by ExtPascal, you'll likely have very quickly a working Web app, albeit without any actual server code yet, mostly just the basic UI, which will resemble your desktop in look.

For best results, I would suggest starting with the SVN files for ExtPascal since SVN now includes the wrappers for Ext JS already generated so you don't have to do that. SVN also includes the ExtP Toolkit. All you would need to test then to test your app would be the current Ext JS 3.1.0 files (from www.extjs.com) and a Web server.

svn checkout http://extpascal.googlecode.com/svn/trunk/ [your_folder]

Thanks.

-Phil

mbohn

  • Full Member
  • ***
  • Posts: 120
Re: application permissions
« Reply #9 on: January 10, 2010, 03:04:32 am »
You should be able to do Options 1 and 2 (uploading) with Pascal using ExtPascal too.

I assume your current app has one or more forms.


No, it is a console app.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: application permissions
« Reply #10 on: January 10, 2010, 03:12:35 am »
Right, although if you put it on the Web users wouldn't work with it as a console app - it would need some kind of interface, as Mike outlined.

Thanks.

-Phil

Troodon

  • Sr. Member
  • ****
  • Posts: 484
Re: application permissions
« Reply #11 on: January 10, 2010, 04:07:40 am »
Perhaps he intends to run it in a console terminal via telnet or ssh client?
Lazarus/FPC on Linux

alter

  • Full Member
  • ***
  • Posts: 151
    • KSP website
Re: application permissions
« Reply #12 on: January 10, 2010, 04:39:23 am »
Perhaps he intends to run it in a console terminal via telnet or ssh client?
Well he has clearly stated that users won't or won't need to have accounts on server which means that running some database server like mysql or postgres would most likely be the case. No idea if the app is a server or is only supposed to do something on server side on demand so it doesn't have to be run whole the time but generally in second case it would mean team your application+php/perl or whatever script language you prefer that allows you to run external commands and can be handled by apache. And of course running apache and some database server (sqlite rather doesn't have multiple users support)

mbohn

  • Full Member
  • ***
  • Posts: 120
Re: application permissions
« Reply #13 on: January 10, 2010, 07:03:42 pm »
.No idea if the app is a server or is only supposed to do something on server side on demand
The latter.  The app is to be run whenever there is a case file made available to it and it then produces an output file and the app is then done until the next case file is available to it.

I can see eventually having a web forum for users to discuss the code.  So that web interface could also be where users register to use the code, enter case files and retrieve results files.

That is all in the future.  To get started I'd like something simple and easy to implement, even if it is not the easiest thing or the fanciest thing for the users.  Fancy can come later.

I appreciate all the ideas.  While I'm an expert on the technology behind my app it should be clear I know little about how to interface it to users via the internet.  My first queries on that subject resulted in a few experts suggesting I first port the (Windows GUI) app to a Linux console app and I'm very close to having that done.

alter

  • Full Member
  • ***
  • Posts: 151
    • KSP website
Re: application permissions
« Reply #14 on: January 10, 2010, 07:11:49 pm »
.No idea if the app is a server or is only supposed to do something on server side on demand
The latter.  The app is to be run whenever there is a case file made available to it and it then produces an output file and the app is then done until the next case file is available to it.

I can see eventually having a web forum for users to discuss the code.  So that web interface could also be where users register to use the code, enter case files and retrieve results files.

That is all in the future.  To get started I'd like something simple and easy to implement, even if it is not the easiest thing or the fanciest thing for the users.  Fancy can come later.

I appreciate all the ideas.  While I'm an expert on the technology behind my app it should be clear I know little about how to interface it to users via the internet.  My first queries on that subject resulted in a few experts suggesting I first port the (Windows GUI) app to a Linux console app and I'm very close to having that done.
In that case I even more suggest writing batch application and using mysql or postgres. First both database servers already have simple yet efficient user management. Eventually if it's not possible to use server's users (database server contains many databases for different applications) writing own system wouldn't take much time. Also then you can use some simple php script to display results and read data from users. Then you would user httpd+database server+your application as a bridge between them

 

TinyPortal © 2005-2018