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 04-11-2024, 01:09 PM   #16
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,863

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311

Quote:
Originally Posted by JASlinux View Post
You can put a standalone portable in a system folder, but they can also be most other locations.
When you put a browser out of the system, it will commonly not run with restricted permissions, logically, when it will run as root.
That is just wrong. The permissions of a process depends on the user who started, not on the location (where is it stored).
Again, all of the processes inherit permissions/rights/ownership from the parent process (where they were started from). Only root has right to modify it. The location of the binary is completely irrelevant.
The access to any file/dir depends on the current user and group (of the process, which wanted to access it), and the access rights of the given path.
 
Old 04-11-2024, 03:29 PM   #17
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,138
Blog Entries: 6

Rep: Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827Reputation: 1827
Simple Example:

A stand alone executable. This will run as the user who ran the executable. Doesn't matter what directory it it in.

cpuload.c
Code:
//gcc cpuload.c -o cpuload

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>

static int cores = 2; //Set number of cpu cores here for cpu usage

static void cpu_load() {
    static long last_user, last_nice, last_sys;
    long user, nice, sys;
    char id[16];

    FILE * const fp = fopen( "/proc/stat", "r" );

    fscanf(fp, "%s %ld %ld %ld", id, &user, &nice, &sys);
    fclose(fp);

    char *percent = malloc(256);
    int per;
    sprintf(percent, "%ld\n", 
        (user + nice + sys) - (last_user + last_nice + last_sys));
    sscanf(percent, "%d", &per);
    printf("%s%d\n", "Percent CPU Usage : ", per / cores);

    last_user = user;
    last_nice = nice;
    last_sys = sys;
}

int main(void)
{
    assert( sysconf(_SC_CLK_TCK) == 100 );
    for(;;) {
        cpu_load();
        sleep(1);
        printf("\033[2J\033[1;1H");
    }
}
Run that executable. Then in another shell:
Code:
ps a -o pid,tty,etime,cmd,user
 
  


Reply

Tags
browsers, limited, security, standalone, ubuntu



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
[SOLVED] How to run a standalone browser in a live session? JASlinux Linux - Software 9 02-28-2024 09:10 AM
search for "standalone" working browser (firefox) surfin_eddie Linux - Software 5 04-29-2014 06:14 AM
Running code on boot as a limited user... itnaa Linux - Software 6 08-25-2007 04:52 PM
Finding Module Dependencies...(Still loading...still loading..still loading..HANG!!!) Aeudian Linux - General 3 08-11-2003 03:31 PM
Finding Module Dependencies.....(still loading....Still loading....still loading) Aeudian Linux - Newbie 1 07-28-2003 02:27 PM

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

All times are GMT -5. The time now is 11:40 PM.

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