Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program happens to use the standard C library (glibc) time function to get the system time. This returns the number of seconds since the

This program happens to use the standard C library (glibc) time function to get the system time. This returns the number of seconds since the Linux Epoch (the start of January 1, 1970 UTC).

Your assignment is to create an alternate version of the time() C library function that will return a value within a time window that will pass the programs validation check.

You will use Linuxs LD_PRELOAD mechanism. This is a shell environment variable that forces the listed shared libraries to be loaded for programs you run. The dynamic linker will search these libraries first when it resolves symbols in the program. This allows you to take control and replace standard library functions with your own versions.

You need to write just one function in one file. Lets call the file newtime.c.

The function will be your implementation of time. Youll give it the same name and it should take the same parameters and return the same data type as the original version. The program validates the time only the first time it calls time. After that, you want calls to time to return the correct system time. Unfortunately, your time function will continue to be called by the program so you will need to have your function dynamically link the original time function and pass successive calls to it.

You will then compile this into a shared library called newtime.so.

You can then preload this shared library by setting the environment variable:

export LD_PRELOAD=$PWD/newtime.so 

and then run the program normally:

./expire 

If your implementation is correct, you will get a message stating:

PASSED! You reset the time successfully! 

If not, you should get a message stating what part of your implementation failed.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What if a1,1 is zero?

Answered: 1 week ago

Question

=+ (c) Show that if & is countable, then f(. ) is countable.

Answered: 1 week ago

Question

Connect with your audience

Answered: 1 week ago