Okay, let's go and get started
Okay, let's get started Good morning. everyone So This is the midterm review and and the midterm is on Thursday, as I mentioned, for you know the midterm is the same format as the
assignment. So you know again, the term is
Okay, so there will be assignment in bright space.
Something of anything else. Yeah. So
Okay, So just quick review what the midterm will be.
The qua I i'm gonna go over while the questions will look shortly the
But first why I wanna just mention real quick assignment.
One has been graded. You should see Marx. Oh, you know her question, Marks.
You have to look for the value. Does this a one?
1, one dash, 2 fields. it's not in the grade book.
It's under progress in bright space because that's where they show text fields in the great book.
They don't show them under the great book because bright spaces bright space.
There is this notion that you can't upload files for for feedback
Yeah, I i've I've looked to that before and it seems very very painful.
Oh yes.
Oh, yes, volunteer for interviews for a one. There are no interviews for assignments.
Their interviews for the midterm. if you want to discuss your assignment, you can come to office hours, and i'm happy to go through things.
But right there
Okay, I have. I have office hours today after class a few of you.
Speaking of officers, I
So just so you know that's i'm I didn't get checked out for t 3 and t 4.
I will do luck, I mean if you're just you couldn't get in this morning.
Come to my office hours I will check you off. But that is it. Okay?
No more guys, though. i'm just giving the small extension to after class, and i'm doing it so you gotta deal with me.
So So the a one a 2 that So the format of a one it it just has the question, number the the feedback.
We go, but it's just the question number and the number of points you've got so it's like Q.
One Colin, one Q. 2 Colon. whatever it's how many points you got per question.
No, no, there's the time block Yes, there is a time block for the
So if you need a accommodations like you have a kind of like Pmc.
College for extra time, and such I will add, in exceptions to your you know, to the assignment, so you'll have extra time to submit it.
But So if you don't if you see the assignment you don't see that please let me know
It says during class that that made in class online is this: Yeah, online during class time.
There is no classroom for this class. So Okay.
So So this all things again I will be i'm also doing the assignment
I would fear some of the north k it's not
The notification bell on bright space. Oh.
So I
Oh, you see, under what Okay, it's under the bell Okay, That's the bell. Icon.
Okay, i'll see you
Okay, i'll put that in there trouble is I can't actually see that version of your interface.
So zoom office hours. Maybe someone can zoom with me on zoom can share their screen, and I can look at the great book, and I can see how it works, because I can get a student. view.
But the student view doesn't actually show grades in it so I can't see where stuff is it's anyway. Great summer.
Okay. So
So anyway, so good. Good! Thank you, thank you all for helping each other out.
Let's go and start wanna start talking about concepts and things but let's go through assignment too.
Bot virus class product cross part grades. Okay, I will check that class progress, progress, class progress.
Okay, anyway. i'll let listen move on from this so
Let's have an assignment to so what internal commands.
Does 3,000 shell to support? Are these the same as those supported by 3,000?
Shell explain briefly. So what did I actually want you to do for this question?
What I wanted you to do for this question was, Wait, let let let me bring up
Let's go ahead i'm going to download this
Solutions.
Okay. So what I expected you from question One, what I wanted you to do was to go through the code.
So what the goal of these assignment may is this: Can you understand this code well enough to be able to make changes went to it.
So what is main? Do main desk setup? So main does the setup of things.
And then, after it does a setup, it calls promptly.
If you look at prompt loop, it was a due. It has a while loop that goes on forever.
It does a print off of a prompt. Then it gets us, gets a string, which is whatever the user entered, and then it parses that string.
So first it divides them into argument, So it gets turns out one line of text into a bunch of separate elements, separate that were originally separate by spaces, and then we check them.
They check the first one to see what the command is. So one built in command here is exit.
Next one p info another one. but come you could argue that ampersand is a thing I wasn't really think of that's command, but it is checking for it so you could and that's it
that's all the internal commands just by way this cause those are the only commands that actually parses.
So I was saying, Oh, you could say the read I I Oh, yeah, you could say the you could do this redirection that yeah, as long as you could do this one. and this one. I didn't really think of those as
mans. But you could argue that those are also parse plan, but I would.
I call those hours, and the other thing commands, but you discussed it in your clean will probably give you full credit
What about the built-in commands like pwd for example, 1,000 shell, 2 doesn't know the command Pwd?
It's not built in
You know, I i'm gonna give us a program that questions that are based on behalf of the Pro.
So if I give you questions it'll be based either on code that you've seen, or code that is either it's very small snippets of code or code that you've seen so you won't have to parse out our
entire new program.
I will work when you try it. Yeah, it works me pwd works because it's an external command
And less than killed. Those are external yeah that's the point e internal ones are built into the shell external ones.
You had to go through exactly e to load another binary like P list.
Yes, exactly. P. List is an internal command in 3,000 shell it's not here in 3,000, shell too.
So that's what I you know
So you couldn't so of these are the same as so for the 3,000 shell like this very like these are close. but so we've got into exit end phone become all external to that show and con only sports it'll commence the
exit B list, so that's the comparison there
You couldn't didn't ask you to explain the concept of internal commands.
So
Oh, yeah, I I guess you can say yeah that that's true yeah, that I mean, for there is the thing are these Yeah, you should say it's like internal command is the one supported in the binary itself.
It's part of explanation but I didn't ask you per se to find it.
Question 2. If you built 2,000, she shell 2 the same as you did.
3,000 shell. What does it feel for command? What if you build it as a user login?
What the point here was, building it as you did through our show, just compiling as a normal binary 3,000 user login.
The make file builds it, but also makes the binary set uid root.
So what I want to say is what happens when you run 3,000 shell to as a regular user, without without the binary having any special, no privileges versus running a binary.
When the binary is set uid root so it's owned by root, and the set uid bit is set.
And so what you should see the regular one just reports uid uidg.
Id this saw there, but if you run it, but if you run the p info, you get uid was 1,000 euid equals 0.
Gid was 1,000, eg. Id on 1,000 so the same thing except Eu.
Id is 0 which means that it's running with root privileges, And so that's what I expect you to see.
And just, you know, to see that Well, sorry. Let me just there we go.
So
They mess up my solutions. Is that Q. 3
Yeah. Q* is about that
It's a question I Are allowed to change uid equals u 0.
What do you mean? Is this acceptable? If you run this
So you could say, you run this as root but you shouldn't be running things by default, as root.
If you got you if you got
Martin, I understand your question. Are you allowed to change uid equals 0?
What do you mean? allowed to change y equals 0, you mean.
Can the process make us make us call to change its uid to uid 0 if it's a quiet.
That's the question to answer it. but yes, you can yes, again, because since Euid is 0, it has all the powers of root, so it can change any of the other fields.
And in fact, it does, and it could just decide to become real, and what what this really means.
This line here. It means that the process is owned by the student user whose user Id 1,000, but it's running with the privileges of root.
So other processes owned by Uid, 1,000 could send signals to this process.
For example, say to terminate it because it's still owned by the same user.
But it's the privileges it can have I what access given is term by this.
So So the basic idea of a set Uid root binary is that the program has more privileges when it runs than the user who started it.
This is a way to get around rigid permissions of Unix to do things like I want you know the user's password is an etsy shadow.
The shadow file is only writable by the root user You don't want every user to just edit at t shot, because they could change the password for anyone on the on the system.
That would be very bad, so we make the password command.
It will edit the password. but it checks to make sure that all it only changes passwords for the right user like if if user student starts it. Oh, it will change the password for a user.
Student, but it won't change. it. for any other user but that's the password binary that's enforcing that restrictions the privileges the password binary has to modify any file on the system
because it is running with privileges so Set uid root binaries are inherently dangerous just like running commands as root is dangerous.
You're depending upon the code to enforce the restrictions on the user who ran the program.
So in that context, the become command in 3,000 shell 2 is stupid, dangerous. if it's wrong if it's installed.
Set you on you route
Aren't there 2 ways to build the programme tutorial for one without set your Id route run with when doing the form or not make a difference.
That
That's true if you run it without set uid route that wouldn't make a difference that's true.
But the make file. so let's go back to that that's a good question here, so let's go back to the make file here.
Okay, So let's go to tutorial for and we go to the make file
So notice what the command does. If you run the make file
When you run make it should just run set. Uid does it so it And and so as part of that, it calls pseudo.
So once you run the make file, it should be set uid route isn't that correct
Yeah, if you didn't want a jason you're right if you didn't launch this route, though you can only change the uid to the true uid or the save you Id yeah there.
Are, if if you're not root you're there are lots of restrictions.
What you can do with these. So what I was assuming is for you to use something like this: make file, which basically means make it set Ui room, which is there in the make file
So that was there. So what's the purpose of line 1 8, 1 8, 9.
So this gets back to the danger of 3,000 shell 2 when it's set you, Id root if the process is set Ui root.
We have the program set. You write your root these 2 lines.
Make sure that if you don't use the become command everything is run as the user who ran the program as a put and not with effective uid of 0.
If you don't have these lines they all get run as root.
So this is. but of course, if it's not set uid route doesn't do anything interesting.
How you can't do anything with those basically those system calls will actually fail, because you don't have privileges.
So So I asked my question here, because I think There's a contradiction question to if you Id equals 0.
You Id goes out. Are you allowed to change your Yes, you are allowed to change uid equal to 0 Martin, because because you're running as with root privileges.
So you can change anything about the profit. Anything on this is including your own uid.
I set you Id root process can't change this uid to whatever it wants.
Yes, line 189 only affect the child process.
Yes, that is exactly right. Yeah, it's cause it but but it's talking about.
Yeah, this is only right for the it's just before the command is executed so.
And then for what's the syntax that become command come user command.
What is the user admin space in the command?
Yeah, I mean. if you just say command we'll probably give it to you without the arguments.
If you just did become user as a syntax that's a problem.
Because so the reason why I say become user syntax is wrong is because if you just type become
So let's see what does it actually do you have to have more than 2, you know.
Have to have more than 2 arguments
Right.
A 0. So basically 0, asking more than one, you know 2.
So you have to have at least. 3 so z somebody's 3 so it's 0 1, 2 so become the user and the command.
You don't have a command, you get in there okay so Oh.
So. And when you said these lines are important because they cause 3,000 shell to drop group privilege before running any programs.
Does this mean that they cause the child process, drop the root privileges?
Yes, remember the parent and child before the exact V are running the same code.
So there are both 3,000 shell 2 euid is what's checked from visions not uid
That's why are you are you does that make sense with your questions or
Okay, So go back to Okay. What more must be true for become command
What must be true before the become command to work that's become available to the programs.
Eu a guy Id is is 0. It is beautiful so there are other that that's true.
The thing I was looking for the basic thing that you know.
If the programs not euid 0 become doesn't do anything I wasn't talking about providing a valid.
We It's also true you'd have to satisfy the syntax of it, where you have to specify that user.
That's a valid user, and a command that actually exists and and and such.
But So the if you set other things, you might get partial credit.
But the really important thing is that you gotta have root privileges otherwise you can't become anyone because that's the point of the command.
The rest of it's just kind of details okay
A no-a. So, Rob, when you say work I don't consider a no-op as working.
If you do something as like you say become student and then do something, and yes, it will technically work, but it didn't do anything, but it's It's it's a no-op operation.
So that, like
Yeah, that's remember
These questions are designed to see if you understand what the code is doing.
If you give an answer that is syntactically correct but doesn't really give any insight into what the program does at best, you will get partial credit.
Yeah, on the tutorial. I I know in the assignment.
Sometimes things may have been great, a little more flexibly wonderful things, but on the midterm you know it's like you need to show that you understand what's going on modify the become command.
So it takes a uid, not just a username.
So what's so? what what people got very confused about this I thought it was a pretty straightforward thing, because begun, takes a user in the command, and then become use.
Put a uid in the command, some people are asking what if you want to put a username and a uid it's like, but that makes no sense.
Because, then, which which are you going to use? the user name or the Uid?
Because you give them both, and they may contact each other or they're duplicate, and then they're redundant.
So why would you specify both? it's a user or a uid?
Because a uid and a username are kind of interchangeable in a lot of unix commands.
So
Yeah.
Okay, and to you you're fine actually
If you did a little compare username with Ascii values.
Sure if you made up your own is digit it's that's fine
Okay? So So so mar I think a question that the question could you be extra specifically wording of the questions in the midterm when you're looking for it's possible some of us are slowing what's important what
syntax, so
Part of this is identifying what's important and I think a big way up.
Do it of understanding what's important is to go what relates to the semantics of things as opposed to what is just syntactic.
You know if it's it's technically true but it doesn't really tell me much
So. I do the the the midterm questions. I do try to make it a little more specific.
But again, this is why you can explain things to explain your reasoning, and your reasoning is in a reasonable interpretation.
The question will give you full marks. So the question is, is that enough?
Yeah, it says, modified to just take a use. it so might take both. exactly.
You know, Z. that that's exactly Why, I want it's not just a username.
So that that's exactly what you want write code for just an explanation.
If you just since I said, modify it. If your description is super precise, we might give you a full credit, but it would have to be very precise.
If you modify to only accept the uid, but not the username, Will I get ducked to this, probably.
Yes.
Yeah, yes, you want to take book again. Why, do you want to take both.
Because that's what makes sense for the command Why, would you change it to just take a uid.
Rather a username you're limiting the functionality
So for a Q. 6 user names can have numbers in them no normal conventional unix is user names can't start with a number.
But that's perfectly fine if you went through and check every digit, and just make sure they're all digits.
Then you did it otherwise. that's fine
But for for question 5 you're saying technically you can still be.
We use become the command. If you become, if you become the current user
It's like I I I don't understand what you're saying for question 5.
Yes, but become student works. but it's a no-op you've got you accomplished nothing by saying student become student running as user student.
So works a command that does nothing. I have a hard time saying that it works.
It was accepted, but it's a no op so
And 20. Yes, that's exactly yeah you your your process is wrong, and if you exclude exit from being an internal command, because if you don't have the logic in the in the shell to accept exit the shell can't
exit with the exit command. If you just probably exit as an external commit.
You'll never exit the shell
Yeah, queue? Yeah, for queue question 5 that still has root root from set.
You guys root permissions. so I don't follow your reasoning it's not what your what you're talking about
So I I I mean we can talk about that later. but I I don't quite understand what you're what you're talking about.
You but anyway, so, so you should be showing this the key idea here is, look at Cs Checks to see if it's a digit.
It is. then we convert it to an integer, and then password entry.
I get get pwuid versus, you know. Get Pw.
Names. So this takes a username. This takes a new Id so do those.
And then get an entry, and then otherwise go same.
How does the behavior of 3,000 shell to change when is run set uid root versus running as root?
You know Cranzo runs the user unless command, you know, become.
Use it as far as route How so th this is the key thing to note that if it's set Uid root commands, we run as a student, user, whatever user you ran it off.
But if it's if you run it as route as opposed to second by any room, then everything is run by route, whether it's with become or not, so all of them have full privileges so
Andrew. Thanks. Yes, exactly.
So this is So this question just basically what i'm looking here is to understand this question is asking what we'll get to this.
It's really asking. Do you understand the difference between set uid root and just running something as rooted because they have different semantics
So does output redirection work for any of the internal commands.
It. doesn't work with exit or pmf but become does work because it's far as before the greatest parson.
So it still works. Okay, And then number 9, the you know, biggest point value question.
So here create a
Yeah, I'm not gonna i'm the biggest point by you.
So 9 create a background command that does all these things. So the basic way I did this is I changed.
So run program takes the art. Take a bystander, just takes the argument.
First, of course I I've added 2 new arguments to it?
And where is one program here? So this is how i've changed one program to have standard error function. you know so originally took standard out.
But I have to take standard in standard out the standard. there.
3 file names. And then, you know, we make the run program on two*, the original one just called, but null into those 2 values.
And then we set those files based on the arguments here background.
And then we change one program. to actually do to have these extra lines where we just set, you know, if you know, if we have a standard function, you open it, otherwise.
You create the output files, the great ones is so you will race them. If they you know, exist, you overwrite them.
And then open you know forces for meeting it you can provide permissions.
So that's what you had to do is figure out a way to do the open.
And then, you know, and then do the do 2 thing
I think we'll probably i'm not sure how much we'll take off, or probably we'll take off if you're things correct.
Otherwise you won't lose much, but if you just made a separate function that did everything basically run program did that's technically right.
But it didn't show you understood the code because run programs almost doing everything you want.
So you just create a bunch of duplicated code which is I mean, which is very bad practice, and it's not showing that you understand the code that's there.
You're just adding new code so that's yeah for if you're watching, I I include the if them that check for errors, yeah, you you did not have to check for errors in fact my original code.
didn't check for errors. so You did not have to have error handling to it.
There was no requirement for that
Yeah.
Oh, I don't know why you don't actually have to read from why you don't read from standard in the program.
You run is reading from standard in you don't read Ronnie
Yeah, Exactly. So that's good so how can you ensure that the new background committed by the become command.
So here 10 shouldn't have wrote the 10 is kind of a check on it.
If you if you implemented. if you implemented this like, I said, with run program, the background command the the background command and the become command can be combined trivially, because you just have to stick in the check on the right part of the
code. If you do duplicated the code, or just another more complicated
10 probably becomes a lot more complicated.
Oh!
Yeah.
So. so, Martin. the whole point of this assignment.
It was to understand that this per was to understand that this is a shell, that this little pathetic little program is a shell, and that it's different from things like Bash, and that, in fact, any program you could potentially treat.
As a shell Okay, anthony let's see what we're saying.
If my command more syntax like background file find it's like background.
5 5, 5, 5 anthony yours isn't wrong per se.
But how did you get? I mean it depends on I mean, if you got if you did something more complex.
So you support in other orders. Sure, but you know again.
My point is what I could have said is how could you do this with minimal changes to your code cause, and and I'm, guessing you had to add about a good bit of code, anthy in order to make the different order of
commands to work, or what what did you have to do to, nor to do that?
Oh, you put the background logic in front of become
Okay, I guess that I guess that technically is fine yeah cause you're saying, Yeah, I I I think that's okay.
I I don't have to look at it but but Anyway, that's assignment to alright for question. I just send you put in the code to do the redirection after you run becomes cause that might not actually work
Question 9, you say, to put in the redirection codes the way you make the file discrete.
Open the file descriptors, and then you do that go? Yeah.
So you say to put them after you run becomes but that might not actually work where you're supposed to put it they don't. Yeah, in the runs there's the becomes command There's a chance that becomes command
is called first, and that might not actually de-escalate your permissions, and then cause the the file descriptor opening to fail.
Oh, so that's that's What I thought you meant by question 10.
So that's that's true it will cause it to fail.
But so it yeah, So if you go that's actually a that's actually a that's actually a very subtle point.
So what it's saying, is normally when you do I o redirection You, the program normally does the open first before you actually give it to cause cause it's possible to have a process be given a file descriptor a file it
does not have permission to open that the the calling program did that permission, but it doesn't so. yeah.
So. so actually what you really should do. so really, what should be done here is this is this, you know.
If new user, this sort of thing should actually be there just before exactly E: Yeah.
Or you put the the redirection at the top before you call.
Who comes before you call before the Fc. : Oh, yeah, yeah, yeah, yeah. Basically, you want it.
You wanna do it so that you don't yeah you just wanna make sure that this happens.
The the changing of the uids happens after the opening happens So that's actually a bug in the original code. Yeah.
So he's if he pulled that out the queue Ted, do we still get the low cause I thought that's why cute 10 was about
Yeah, I think i'd give you points for that alright very nice. Thank you.
Yeah, because because that's because you're right that that's interaction between the 2
The code is weird for output redirect you saying in general, or just this implementation: Oh, yeah, you have.
Yes, it's it's a very the syntax for 3,000 shell is definitely not shell standard It does not support all the operator to standards, you know.
Bash supports. Is not posix compliant by any means?
Yes, it's very happy. but that's program Oh, which you didn't know until after you submitted the assignment.
Oh, yeah.
What was going on
For question 10 you saw how the increment the arts are right.
Oh!
Oh, so why do you have the close The close is important, because otherwise you will.
Just you basically have used up more file descriptor you'll have the same file open or 2 file descriptors, and they will stay that way for the new after you do it.
The exact fee so it's just messy
So the reason so, Martin, the basic reason why I say I don't give out solutions for the tutorials is because the solutions are not the important part of the tutorials.
Okay, that's not the important part the important part of the process and let me show you why.
Because we're now going to start making up questions for the midterm
So this is so let's let's talk now let's see so
So i'll tell you the midterm has not been finished yet.
So if I come up with good questions here, they might just show up on the midterm, and if you help me, come up with one, you know, to make it at it.
So the way basic way I structure these things is I start with the solutions to an assigned.
I start with the assignments, and then I put them here.
But let me What's each of these let's walk through them and walk out.
They go from the tutorials, and how they
You know so, and and see how that works so you go to So what i'm gonna bring up i'm gonna bring up a sign up one solutions Now
So there. So this one. So let's. start with this first question: There are 3 functions defined in 3,000 menu, which lines of 2,000 men us implement each of those functions.
How do you know these are the correct lines? So
There's a fee do you have the feedback there's not feedback.
There is the marks per question for assignment. one as I talked about the beginning of lecture.
Anyway. So let's so we're talking about here, the 3 functions defined in 3,000 menu which lines in 3,000 may input each of those functions.
So whether those correct lines at let's first look over here i'm gonna take this question here.
So what this is, how I I actually do things like. First, take the question over here.
I copy all the questions from the assignments. to to my exam paper, and then I start editing them. Let's go.
Let's go back and let's look at the tutorials.
So this was all from tutorial, too. So what was tutorial to all about?
It was all about. You know. How do programs fit together and stuff?
So that and then we look at 3,000 menu. You know the 3.
This is asking about understanding those. So all throughout, this you're supposed to be looking at the assembly language and trying to understand how the Assembly language worked.
So if you spent time and you were working these things.
You were doing a lot of open-ed exploration of how these things worked.
I'm not looking for specific answers for this tutorial is looking for you to explore these things.
But now here, i'm getting you to think what actually is happening here, what would I ask you about on the midterm for this
Ricky, the questions that you got right or wrong are there?
Look at the beginning of this lecture. I explained it, and other students did so.
Then the meeting reference programs in a assignment one and 2.
Oh, it will include listings with the midterm, some of which will be for code that was on, you know, assignment one and 2.
Some of it may be variations on them, so variations on it.
So here we have. What am I really asking about there? What lines implement each of those functions?
Say, can you read assembly language? hello Can We see the structure of functions?
So let's go. look at the code. from here. so it makes sense for me to show a bit of assembly language here, and what I could ask about is, you know, Let's say your chances into really like
Used to
So like this is so. This is saying what the same language instruction is used to call a function.
What is instruction is used to return from a function You should focus on the topics being mentioned in the assignments. Exactly so.
What's the answer to this question? first part is it is it the word call, hey?
X c. c. e at t l T. and that's like calling the function like C Cv. and we get some plot.
It's just like syntax needed to do it it's.
It's based the P. No. the plot is referring to that basically allows it to be position independent code.
It's referring to a table set off offset, and it's re you.
Yeah, you call the you don't call a function with a jump.
You use the call instruction, and then you use wreck, and the reason you use call instead of jump is because call saves the return it. the current address onto the stock, so you can return from it.
Otherwise return doesn't work
So if a function was implemented as a label
What else would it be in a assembly language it's all labels?
Yeah, that's they're just I mean labels in remember an assembly language.
There's no semantics associated with an address it's just an address.
We? What would you do with it is
Yeah, what is the function Assembly? This is a function and assembling.
This is it
Yeah, you know, this is it like there is one program. This is the implementation.
But there is no concept of a function in assembly except for there's kind of a subroutine concept, but just so much as the call instruction implements.
It but that's just it doesn't even take care of how arguments are handled that's all convention call is just you jump to some place and then save the current address on the stack, and then return pops it
I get calling a function. Sorry is you use call and that's how it's used to call a function.
But then, what's the difference between call and dot cfi underscore start?
Proc. So what are the things starting with dots
They're directives. they're things that tell the assembler how to work.
Notice when you disassembled the code. nothing that started with a dot showed up.
They aren't actual instructions
Okay, Thank you. Does that make sense? Yes, thank you there's instructions?
And so like here, like this is all saying like here's where this thing starts for managing the generation of code with how is it going to organize? It's all just helping it with that.
But now we're actually defining we're saying the type of run program is a function.
So there is this type thing, but assembly doesn't really have types.
It's more used for other things so so so but so zoom. Actually, this would make this a perfect question for the midterm precisely because saying, you know what is used to call a function.
You use call, and what's used to return from a function is Rat.
It's like, I give you the answer in the question is like I kind of I mean that that yeah, so just because a question seemed like the answer seems obvious.
Doesn't mean it's wrong part of note of knowing material is realizing the obvious answer is the right answer. I'm not saying some questions.
Aren't going to be tricky but some of the if you think every question on the midterm is tricky you're doing it wrong.
Most of the questions, at least half the questions will be very straightforward, but a certain fraction that will be tricky. Because again, I have to test to see.
Okay, you have basic knowledge, if you have advanced known, gives me a mix of difficulty.
So, and they Won't necessarily be in a specific order so when you answer some, if it seems like obvious as to go and answer it.
But then go like wait. I gave an obvious answer for all the like.
Wait, which ones are more subtle it's worth going back.
Maybe I you misread them. This is one reason you always good to reread the questions.
After you didn't know leave some time at the end to review your answers.
So so, Alex. i'm not going to ask a question that it's so on the midterm i'll be much more precise in what I want you to add answer so so like the whole directives and other things it's
like i'll have to put some qualifications in to say that, and actually, honestly, these it's kind of a There's multiple answers that we can accept for that so
What? what a good question do, So I just want.
So So so saying, you're saying like question 5 and assignment to the user needs to exist to become for become to work. he's obviously not what you're looking for.
Yes, there's also the things that are kind of like well, of course, that user would have to be otherwise.
How could it ever work That's not really getting at the semantics of the problem?
There is, there are judgment calls in coming up with what's the right answer for some of these things you can't just, and if if you give your interpretation, your interpretations reasonable I will accept different answers, but you
know. Think through. Why, you're answering what you are go ahead.
Someone's talking. So what a good question the like? Look at these couple lights of code in the assembly.
What does it do? Exactly. That would be a that would be a great kind of question, because that's what you had to do in the assignments.
Just couple of lines like, What do these instructions do?
So that gets up to like, Okay, Well, let's go through the solutions here.
Yeah, we're running out of time. here. so let's just go through there. let's i'll just go through the questions really here. and then we can just talk about So there are 3 functions defines in what you know So this what
is this question really asking about is asking about do you understand where functions start and end in assembly, and what it means to enter a function.
It wouldn't mean to exit a function do you understand those concepts. so i'd want to and here.
I'm from Get the concept of external variables and how ex what extern means in C at the assembly line below?
The idea is externally becomes like you just it's not declared.
There's just use really extern is to allow see to use symbols that aren't defined to be used simply to let you use them.
What's 3 asking about here? i'm saying is how is data?
How is constant data defined in assembly? So a great thing for me doing?
3 would meet to give you some of assembly languages for a simple data structure.
And then you tell me what will be the seat Declaration of it.
I wouldn't want to do something completely different but I might do something involving pointers an array of pointers to strings, or something, or maybe an array of integers or array, points something that looks pretty
straightforward, and that that would be, you know, for so it is just less of a 7 month, for, like a question referencing is 7 2.
What would it be like Here's a bit sharing of permissions?
What permissions does it have yeah exactly but I Don't think I had that much on provisions in any in either assignment.
So I I wouldn't probably ask that because I didn't really ask you to analyze that directly on an assignment.
So, or would it be Here are their uids tid and the effective ids.
Would they have to write permissions to do so?
This come in? Yeah, Exactly. yeah. If I say this process has these permissions, could it do?
X. or I know here's a file with these permissions could it read it or not?
Why why not so? yeah That that that could be that's something like that interpreting permissions?
I'm probably not gonna do so much file permission based things, cause I didn't really test you on that.
We're gonna see much more file permission based things afterwards, because we would talk about file systems. We're gonna get to the integrity of how all this works.
So here what i'm looking for here with 5 is understanding how memory allocation happens in the sense of memory allocation happens.
What's the big concept here? is that memory has to be allocated from the kernel using different system calls but small memory.
Allocations are not necessarily done. Do not each in for call, make a system call happen.
So I want to test that concept.
So if you wanted to find out you, you assign one feedback.
You can come to my office hours but remember that you're the the grade you got for each question is there in bright space?
It's under progress. Look up in the chat we explained it.
I I know. so let's talk about my job my office hours my office.
I was on my in my office hours zoom which is separate but it's on bright space.
Not in this, not here. kore a lot. to know how many questions will be on the midterm.
Well, I haven't finished making it so tell you i'll post it.
You have a you have a guess like how like out of how many points it would be, I typically do it around 30 points.
Okay, alright, that's the quick I basically plan on if you know the answers. If you have a very good understanding of the material, you'll probably take you between 30 to 40 min to write the answers and the rest of the
time is, is basically thinking time. So here in line 3, all right, we replace one of the string pointers and menu with No.
So here this is what really this is asking about is what does exact meet mean?
What as an argument that's really what this question is about is what does exactly you do?
And so so do you understand what the parameters are to exactly, and why it needs those now release environment.
Variables command line variables. how does 1,000 sees menu behavior change?
If you delete line 34 the call to wait here again.
I'm trying to see do you understand the idea of a process of a parent process calling, Wait to wait for the child process to exit, and how that relates to running through the background or not and stuff, and how signals are that's what
i'm this one didn't actually do signals lace line 29, and for that menu with the following 2 lines: So here is I'm saying the Jefferson library calls and system calls that's the really big
thing. Do you understand the difference between those 2 that in assembly language you have to make a system.
Call at the Cisco instruction to make a system call but we don't.
You can't generate that directly from c you have to have in line Assembler. Some other compiler directives. so normally, what we do is we call a library, which makes this call instruction.
For us. But there's no reason in principle why we couldn't do it ourselves, except it being i'll pay in the buy, and also normally, you don't wanna you don't wanna deal with higher level interfaces for
most things than actual low-level system calls that's really what?
This question is all about, and then so let's so switch to assign 2
Yeah, it's 80 min Yeah.
You'll know how many points each question is worth i'll give i'll note how he points is beside each.
Yeah.
So let's go through these questions no thursday you don't need to come to the lecture. Zoom.
Yeah, midterm will be easier than the assignments but it's time limited.
You have only 80 min let's look through this so what internal commands?
Does 3,000 shell to support. Are these a support special?
So here. Do you understand the difference between internal external commands?
That's what that command is asking and can you read if statements come checking strings.
So that's what question one is so question 2 if you build 3,000 shell to the same as you did 3,000.
Shell. was a Pmf report. So here again, trying to explain, Do you understand?
Set uid root. Do you understand what it does to the uid and the and the Eu Id and the difference between those 2?
That's what this is about what is the purpose aligned here again. here.
This is talking about dropping privileges and Why, you'd want to drop privileges if you're a set uid root binary, because otherwise you're gonna run everything as root and the whole point would set your any bundle is to
limit. What you can do is route because the regular user didn't have root privileges, but this program does one has to act uses, privileges wisely
You find internal commands using help i'll be on zoom to answer questions internal commanding and help No offer a standard shell sure
The midterm will be for this amount a assignment one and 2 in this semester.
I don't go back to the past one because that would not be very fair
It should pass the validator. there'll be a validator for the midterm
That's wrong. Jason the file descriptor standard input is 0 Senate output is one.
So if it talked about standard input and said one it's wrong.
Oh, yeah, that was from one of your previous midterms.
So I was wondering if the answer is wrong then, I Yeah, my answer is wrong. I I had a brain fart when I did that i'm sure cool.
I but honestly, I would not I mean it's good to look at the previous midterms.
If you wish to see you like how they relate to the assignments.
But i'm covering slightly different material here the emphasis is different.
There there will be a validator. Yes, yeah i'm just looking to like relate to what we previously learned.
And yeah, yeah, if you all look at the assignments of the midterm. But if you study the previous year's midterm, you'll get they'll emphasize concepts that i'm not talking about so
much, and this one emphasizes different concepts.
So. Yes, thanks for everything. There is going to be a validator just that has been for the 2 assignments.
So So since this off a book are we allowed to access online resources, right?
Yeah, just don't talk with people but as you know Most of these things are not very googlable.
I know so he said. he'll be on like teams.
So they're in their mid turn should we message you directly you should either show up on Zoom and ask me, or come or message me on teams.
So I would suggest coming onto Zoom, because I think it will be faster to talk to me rather than text me. Yeah.
But like for the people who can't like so like a direct message.
Okay, So let me. I wanna i've got a couple of minutes here.
So i'm gonna focus on going through these questions here.
Just, you know. Again, concepts are literally go. question my question.
Do you understand the concepts behind these things? What is the syntax of?
Become command what must be true for the become command to work again here.
This is all understanding the whole set uid stuff and the syntax and go like, Can you read code?
Can you see what's there you know that was like work like, Understand those couple of lines there so modify so like what I could do for this is I like, give the implementation of a new command and like what does it do almost tempted just
to give a small small C program that just parses a string and does something.
So, because it seems like so you have difficult that so modify the become command.
So it takes a uid, not just a username.
Again, just understanding the the difference between user names and new ids.
And oh, just in terms of permission. model there. How does behave through that shell to change when it is once set your room?
Notice a lot of things about set uid route here in this assignment set you, Id and you know that whole model.
So there's gonna be some questions on it does apple read, actually work for any of the internal commands.
So here, what i'm really asking about is do you understand how output redirection would you notice how input redirection works? No. Do you understand that?
You know, What does it mean to redirect standard input standards?
Do you understand those as concepts? How do you guys, Now that gets implemented into code in a shell, That's that's what else.
And then background here, background is like, Do you understand the concept of a background process versus a foreground process.
So all about how weight works and stuff
How can you show the new background? Come on, come to answer
You're gonna be more analyzing code if you write code.
It'll be like one line one or 2 1 2 lines at most.
I mean it's not i'm not having to write Major Ports in the code, because writing code takes time you've got deal with all the syntax.
I'm not going to be compiling your answers i'm going to be.
We're gonna be leading them and trying to interpret them So so you need to.
Yeah.
Yeah, I So So I understand that wanting specific material to study
More theory not theory it wouldn't say my tests are gonna be more theory like I I the the test.
The questions are applied. and actually, what I really want to do is see, can you apply these concepts?
2 things. So if you want to see the kind of questions I ask there's years of past midterms you know.
Just go and look at them. You can see the stop, the the style of questions I. so they tend not to be theoretical
Anyway. unless there are any more any more questions
Am I going to repeat assignment question i'm not going to
I might repeat them again. it's not I I base them all of the assignment.
But I will change them around. My goal is memorization of yeah
The first off to that
Professor th the the midterm is not an assignment it's a midterm.
It's an exam which means that I have you i'm checking to see if you know things I don't have much space for you to explore.
To figure things out so sorry. we don't understand everything on specifically tutorial for but but I know ssh is not part of it.
But if we understand the assignment, just as a prep do you think we should just make sure understand everything on the assignments? And even if you don't get anything on everything on the tutorial, you should still be
fine. So you have to be careful. that when you say you understand the assignment question that you really do because ultimately these are webs of concepts like That's why I don't sit.
Why, this is why I don't just say like based on what I talked about today.
You I give you, though there's a list of topics that I mentioned as I went through the questions.
But each of those concepts are connected to other concepts and So if there's a chunk of the tutorial that you didn't understand that actually is part of the concept behind a question on the assignment that could trip you
up. I guess my question is with regards to 3,000 user login and how you're bypassing it.
You know, using the sort of when you're using the ssh!
And giving it root privileges. so I understand you know what it means to give some something root privileges and setting something.
But i'm still not clear, very clear on the how the Ssh actually bypasses the key bypasses.
The need for a password Okay, that's a separate thing that that's not there. So all that's happening. there is.
So what there is is There is a when you're sshing in the key is just a substitute for a password.
That's all okay, So what is normally it always do a search whenever, even if we have, if we have a password, does it, Still, there's a hidden step where it looks for a key?
And if there's no key to backup is a password or vice versa, and that's why you, if you looked at Ssh. V.
That's exactly what it does you see all the us Okay, perfect.
Thank you, are you, Professor? I am still not very sure about Question Number 3 for assignment.
2. so when you set a uid with using command and the you said the effective uid for the for the use it to route, and then when you run it.
And then the you are not on understanding the what's the point? What is that piece?
The point of view. Id because you have effective view. ids always 0 when you said So it's not so so at this point in the code.
So this is, these are the lines you talk i'm talking about right, So if we're saying there's a use, so we run become user that.
But if we're if it's not become user we're supposed to run the command as the user that ran the program, so we should run it as student.
If you take away these lines, what does the shell do when you run a command?
As what user does it run the rise? the with the net line?
Who lines the logic user. It runs as root, because the effective Id is equal to 0 and so after the Exec Ve.
If you do it, what you should have noticed is when it's effective uid is 0.
You do, an exactly e. Then the uid becomes 0 the uid becomes So I actually took out these 2 steps, and then I run and I do a premium p info and then don't see the uid getting
changed p info doesn't change an id cause p info is an internal one.
It does It's not affected by new lines But if your type Id Id does change, Okay, got it.
Okay. and the other thing is then the after you change this.
If you change it in the in the trial process, does not affect the
The permission setting in the the parent or not. What do you think?
I would say no, Exactly. cause processes are separate. And can we also say that this is using us at least like a reset in the sense that you basically you always return it to its original state.
So that the they say you become a user after you become a user, You this specifically is dropping privileges.
That's the term for this basically the process is privileged it's getting rid of its privileges before an exactly E.
So the new program does it isn't run with privileges Okay, thank you.
Output redirection. is it's a it's always an abstraction added by the shell background.
Also does output redirection, anyway. i've got I mean okay.
So ricky rug i've i've gotta get going here to the office hour shortly, and you welcome to come.
Follow me to ask questions there, but Ricky, go ahead.
Basically, my question is that for the become output redirection?
It didn't work for me, even though I use like a fresh 2,002 shell file like from the assignment.
I didn't make any changes except gave a route to the privileges and set the spit.
It didn't work for me because I was getting the file access denied from permission denied error.
So the way that I changed it was that I in the I just changed the Sd.
Out file to be opened in the switch to Users Home Directory.
Okay, you're you're Okay, I think you're misunderstanding something in your steps come to my office.
I can walk you through it. Okay, Rogan, you know. Sorry.
I just wanted to ask if none of the office hours today, or tomorrow, work with me because I have other classes, but I still i'm still not really understanding the set to.
Id a part of it. So what do you recommend? I should do?
Well message and like, try those things. And potentially, you can talk to a Ta or me like just you know, messages with the question like email or team teams.
Okay, Okay, I'm heading to office hours Now really quick.
Carson, I I think you're basically right but alright have a good day.