prushik on 7 Nov 2016 17:42:35 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] LINUX LOW LEVEL PROGRAMMING QUESTION


---- Original message ----
From: JP Vossen <jp@jpsdomain.org>
Sent: 11/07/2016 20:18:09
To: Philadelphia Linux User's Group Discussion List <plug@lists.phillylinux.org>
Subject: Re: [PLUG] LINUX LOW LEVEL PROGRAMMING QUESTION

On 11/07/2016 07:59 PM, Ronald P Guilmet wrote:
> The problem:
> I have a Dell laptop that I cannot adjust the screen brightness via the
> settings shown to me. I can however change them by echoing a value to
> the /sys/class/.... file. This is not distro specific, it doesn't work
> in Ubuntu or Fedora. I am currently using Fedora 24.
>
> suid is disabled in Bash for security reasons. I can execute an echo
> <value> > /file/path and it works. If I put that in a bash script and
> run it from the root command line, it will not execute. No errors, it
> just won't change the values.

Note that bash is not in charge of suid. Also, note that everything in /sys/ is not a real file, its more of an interface to the kernel. An arbitrary node in sysfs will only change if the kernel tells it to e.g. if your write is accepted and processed by the kernel.

> My programming experience has not been low level, and this seems to be
> low level programming. I have a familiarity with C, and I'm thinking I
> will try that.

The only really low-ish level programming needed for this would be if you wanted to take advantage of seteuid (suid). Otherwise its just opening a "file" and writing to it.

> I've looked up solutions in the past, but they don't seem to work anymore.
>
> To fix this, and to satisfy my love of playing with Linux, I was
> thinking of writing a C program that either reads a config file, or a C
> program that will accept a parameter (screen value) giving at runtime.
>
> Anyone have any suggestions or comments?

I agree with JP, seems like your issue with your script is an issue with your either your syntax or the way you are calling it, and not an issue with how bash works. However, your idea of a c program that does what you want should be pretty simple to implement.

 - Phil


___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug