myshell | Simple shell program for HKU COMP3230 Principles
kandi X-RAY | myshell Summary
kandi X-RAY | myshell Summary
Simple shell program for HKU COMP3230 Principles of Operating Systems.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of myshell
myshell Key Features
myshell Examples and Code Snippets
Community Discussions
Trending Discussions on myshell
QUESTION
int main(void){
char cmdline[MAXLINE];
while(1){
printf("> ");
fgets(cmdline, MAXLINE, stdin);
if(feof(stdin)){
exit(0);
}
eval(cmdline);
}
}
...ANSWER
Answered 2022-Mar-24 at 12:10The confusion is to assume stdin = terminal. It is not necessarily true.
What stdin is depends on how you run your program. For example, assuming your executable is named a.out, if you run it like this:
QUESTION
In an Angular 12
project called myShell
, I've implemented an nx
monorepo, then defined my project as a Webpack 5 Module Federation
micro frontend shell
using the command ng add @angular-architects/module-federation --project myShell --port 4200
.
Now I'd like to use the Angular CLI
to generate a new micro frontend remote
, which I'll name mfe1
. How would I accomplish this with the nx
or ng
CLI? For example, if I navigate to my apps
folder (which contains the myShell
project) and do an ng new mfe1
, I get the error message: The new command requires to be run outside of a project, but a project definition was found at ...filepath/angular.json
. I also can't run an ng g c
, since an Angular micro frontend app is more than a simple component.
Is there an Angular CLI
command that I can use to create a new micro frontend remote, or must each remote application be created tediously by hand?
ANSWER
Answered 2021-Jul-07 at 11:34The ng new
command will create a new workspace. So you can't use it inside a folder alread containing an angular.json file.
You can create a new angular project inside an existing workspace with the command ng g application
For exemple :
QUESTION
I tried to make a return to libc buffer overflow. I found all the addresses for system, exit and /bin/sh, I don't know why, but when I try to run the vulnerable program nothing happens. system, exit address /bin/sh address
Vulnerable program:
...ANSWER
Answered 2021-May-17 at 02:56First, there are a number of mitigations that might be deployed to prevent this attack. You need to disable each one:
- ASLR: You have already disabled with
sudo sysctl -w kernel.randomize_va_space=0
. But a better option is to disable it only for one shell and its children:setarch $(uname -m) -R /bin/bash
. - Stack protector: The compiler can place stack canaries between the buffer and the return address on the stack, write a value into it before the buffer write operation is executed, and then just before returning, verify that it has not been changed by the buffer write operation. This can be disabled with
-fno-stack-protector
. - Shadow stack: Newer processors might have a shadow stack feature (Intel CET) that when calling a function, stashes a copy of the return address away from the writable memory, which is checked against the return address when returning from the current function. This (and some other CET protections) can disabled with
-fcf-protection=none
.
The question does not mention it, but the addresses used in the code (along with use of long
) indicate that a 32-bit system is targeted. If the system used is 64-bit, -m32
needs to be added to the compiler flags:
QUESTION
I'm currently working on an assignment and am trying to compile it using a makefile, which currently looks like this:
...ANSWER
Answered 2021-Apr-27 at 17:48You should use -c
option to have GCC do compilation only (create object file, no linking to build an executable) and -o
option to specify the output file, not one of the input files.
QUESTION
Working on a project for a class. We're supposed to write a C shell. I've found a bunch of good examples, but for the life of me, I can't get my version to generate any output.
It keeps printing the prompt, but nothing else.
I've followed along with some examples near-verbatim trying to fix this, but still nothing.
...ANSWER
Answered 2021-Feb-06 at 05:18parse()
returns a pointer to the local array args
. Since the lifetime of args
ends when parse()
returns, any attempt to use the return value of parse()
is undefined behavior. You should allocate that array with malloc()
instead (and free it later!).
What happens in my test is that the compiler notices that the return value of parse()
can't legally be used (and it gives a warning!! which you should read and pay attention to!!), so it just returns NULL
instead. When the child dereferences this pointer as *args
to get the first argument for execvp
, it segfaults and dies without calling execvp()
. You could detect this if you checked the status
returned by wait()
, but you don't. So it just looks as if the child didn't do anything.
Oh, bonus bug: when end-of-file occurs on stdin
(e.g. if you hit Ctrl-D), the string returned by fgets()
will be empty and strIn[strlen(strIn)-1]='\0';
will store a null byte out of bounds. You need to test the return value of fgets()
.
QUESTION
ANSWER
Answered 2020-Oct-17 at 18:32This problem is more complex than it appears due to the interplay of the shell, the terminal, and your program.
Given that the requirements are:
- Custom shell prompt
- Custom commands
- Have the shell work normally
- Intercept the program output
My suggestion is:
- Do the customizations from the shell side
- Create a pty to fool programs into thinking they're writing to a terminal. In Java on Linux/Mac, a simple way to do this is via the
script
tool.
Here's an example shell configuration file myrc
:
QUESTION
I have created two name-spaces named 'a' and 'b'
I have file structure like below..
on folder a
nginx-deployment.yml
...ANSWER
Answered 2020-Aug-21 at 13:22You need to allow egress on port 53
for DNS resolution
QUESTION
As I am new to yocto, I've been trying to make a recipe from simple C program which uses makefile to generate the binary. After creating the recipe I am getting the following error
...ANSWER
Answered 2020-Jul-11 at 10:15Error occurred because you have CC = gcc
in makefile which points to compiler in host
. This overrides CROSS_COMPILER
set by yocto. so the binary you built hello_shell
is for host (ELF 64-bit LSB executable, x86-64), which throws error while using aarch64-poky-linux-objcopy
Try removing CC = gcc
from makefile
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install myshell
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page