Processing Linux SIGnals using Gambas - linux

I would like to send a (as yet undetermined) SIGnal from a bash script to a Gambas program when a specific file has been changed.
How can I get my Gambas program to process this SIGnal?

The gb.signal component allows you to manage signals. You can intercept them, ignore them, and so on. See http://gambaswiki.org/wiki/comp/gb.signal for the details.

If the documentation is anything to go by, this doesn't seem possible. However, I would suggest asking the same question on the Gambas mailing list (and/or link to this question on Stack Overflow). Please report back if you get an answer via the mailing list.

According to http://www.mail-archive.com/gambas-user#lists.sourceforge.net/msg01890.html and http://www.nabble.com/Question-about-signal-management-inside-gambas-console-program---td20626972.html, it is not yet possible.

Related

Using the Linux kernel in my operating system [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 4 years ago.
Improve this question
PREFACE
I tried to put as much effort and work into this question as I reasonably could, so if you could at least read it through, I would highly appreciate it; I, also, have tried researching this question, but I never seemed to find anything useful, in terms of anything that directly answered my question; I do not know if this is right place for this question, even though it is related to programming, it is more related to operating system development and the Linux kernel, and if there is a better place for this question that I am unaware of, please move it there; feel free to do whatever, edit the question if need be, I do not care, I just need an answer to this question, because this is stressing me out.
The following is some background on why I am asking this question; if you are uninterested, and if you just want to see what I am asking, then skip to the 'MY QUESTION' label; I thought that I would put this is here, so that anyone who is reading this question would know why I am asking this question.
BACKGROUND
I have recently begun setting up an operating system development project; and after I get some things ready, it will be only me working on it, as of right now, and I plan to write the whole thing (yes, I know it will take a whole lot of work, but I can try, right? :p), including the bootstrapping, the CLI, and most of what is necessary to have to either my own kernel or Linux kernel function; GUI and much more; granted, eventually I may end up having a team, but that is for the future.
MY QUESTION
My question, which is actually consists of three parts, and I narrowed them down to specifically those thee things, which are the following:
(1) If I were to build everything else, and use the Linux kernel as-is, and if I were to not tie the other parts of the system into the kernel, but use the kernel for I/O and system calls, would I be violating the GPL in any way, and would I think need to open source the rest of my code?
(2) If I were to only use the kernel for I/O and for system calls, but not have the code that I wrote actually interface with any kernel functions, would that still be considered linking?
(3) If I were to do the above, would that be considered a derived work, when I wrote everything else, but used Linux as the system's kernel?
All these legal issues are making my head spin and extremely confusing to me.
No
No
No
The linux kernel considers the system calls a boundary, and code that communicates with the kernel via system calls is not covered by the licensing of the kernel. So, the user space code you write is not a derivative work of the kernel.
There's also a set of header files provided by the kernel, collectively named the UAPI headers which you can use without having your code become a derivative work
This is covered at https://www.kernel.org/doc/html/v4.17/process/license-rules.html and https://github.com/torvalds/linux/blob/master/LICENSES/exceptions/Linux-syscall-note
If you need legal advice though, contact a lawyer.

How does towelroot (futex exploit) works

There is a security issue in linux kernel, which affects most of android devices and basically allows any user to become root.
Since I am linux user for quite some time, I am very curious how this exploit works, especially how can I check whether my kernel in my PC (custom built) or on any of my servers, is vulnerable to this or not. Is there any source code (preferably documented) or details of the exploit so that I could see how it works? I could only find the generic information or closed source binaries that do exploit the bug and give you root if executed by any user, but no background information or details of which part of kernel has the flaw and how is it even possible to do this.
So far I found this interesting article http://tinyhack.com/2014/07/07/exploiting-the-futex-bug-and-uncovering-towelroot/ which explains that it uses stack hack, by calling certain syscalls in order to get something into a stack of futex_queue. While I understand how that works, I have no idea how changing anything in that stack can actually elevate privileges of current process. What I found interesting is, that this guy say that since kernel 3.13 something has changed and now different technique is needed to exploit this. Does it mean that this was not even fixed and is still exploitable in recent kernel that can be downloaded from kernel.org?
As SilverlightFox said, the Security portion of stackexchange (http://security.stackexchange.com/) probably would be better for this, but here goes nothing.
From the sound of it, this hack appears to be a way to elevate any users' terminal/kernel for a given amount of time, which is, not to say the least, bad. My idea of how this sort of issue would work is a program that overloads the futex_queue by calling those said syscalls and then provides, temporarily, the user with superuser access.
I looked around at the link you provided and found that it does require remote login from SSH or similar procedures. In a console screenshot, it uses the line gcc -o xpl xpl.c -lpthread, which shows that this exploit is done in C. And a quote directly from the article:
This is actually where the bug is: there is a case where the waiter is
still linked in the waiter list and the function returns. Please note that a kernel stack is completely separate from user stack. You can not
influence kernel stack just by calling your own function in the userspace. You can manipulate kernel stack value by doing syscall.
In the image at http://www.clevcode.org/cve-2014-3153-exploit/, it shows the output of the towelroot exploit, testing the address limits and getting into the task structure to spawn a superuser shell. Also, in the tinyhack article, it gives a simple recreation of this exploit's base, so I'd recommend taking a look at that and working from it.
I don't know any clear form of testing if your system is vulnerable, so the best I can tell you is to try and harden your systems and do all you can to keep it protected. Anyway, I don't think that someone would easily get hold of server ports and logins to run this exploit on your system.
Cheers!

Make changes to embedded linux kernel code

I'd like to understand & edit(adding printk, etc.) the linux kernel for a craneboard, which I obtained from github. I'm a newbie. I have gone through certain questions related to this in stackoverflow, but they all concentrate on linux in PC (not in embedded!). I don't know where to start. Any kind of guidance is accepted. Thanks in advance.
Dear did you got chance to look at README located at
https://github.com/craneboard/craneboard-kernel
if you need to add any information or some logging i.e. adding printk in kernel itslef, you need to recompile it, it also shows how to do it. But i am interested to know why you need to put logging information in kernel? Are you going to fix some bug in kernel?
Printk is same like a C Printf, but with few differences http://www.makelinux.net/books/lkd2/ch18lev1sec3
Also have a look at http://processors.wiki.ti.com/index.php/CraneBoard
It might also be a good start to look at https://linuxlink.timesys.com/files/pdf/Timesys-EmbeddedLinuxTutorial.pdf
You'll need an ARM toolchain before you can compile the kernel. Here is a good tutorial.

Internals of systemtap

I want to know what actually happens internally when the event written in the tap file occurs and how it is handled?
You should read the documents presented at the end of the SystemTap Documentation page, especially the Locating System Problems Using Dynamic Instrumentation OLS paper, to know a bit more about the internals.
The Introduction to KProbes article at LWN is worth a read too.
You can explore as deeply as you like. The architecture paper or the stap(1) man page are a good start. If you want to know everything, "stap -k ..." or "stap -p3 ..." lets you inspect the actual internal outputs of the systemtap script translator: the compiled C version of the script code.

How to use 'copy_to_user'?

I have to add a system call in linux kernel that will print the process tree showing only the PIDs to user code. I have to use copy_to_user here. But I am not understanding the use of this function. Could any of u give an example of how it works, including the user-side code and added system code?.....Any easy/simple example would be great for me...:)
Thanks.
I suggest you read through the Linux Device Driver book. It's freely available online at http://lwn.net/Kernel/LDD3/. Although it's geared towards device drivers, it covers most of the key aspects for communicating between kernel and user space and includes multiple examples.
By the way, this sounds like a homework question. If so, your question should have the 'homework' Tag associated with it.

Resources