How to set a static system date for one user or application--"Groundhog Day" - date

I have a vendor application on AIX which requires the system date to be set to an arbitrary value for QA testing purposes. The application gets its date from the system, and there is no possibility of changing it to get the date from a parameter. The application runs under a specific userid. I'd like to find a way to set the date for this application or user to a private value without affecting all the other users and applications on the system. So far the only thing I have been able to do is dedicate an LPAR to this application. Every day at midnight a root crontab job resets the date to the static value. This works, but it is wasteful of resources; and now I am faced the requirement to do this for other applications, which, of course, require different dates. Is there any clever solution to this? I need a way to create a sandboxed environment where the date returned from the system can be set to a private value. As I said, the OS is AIX, and that can't be changed for this application either.

You might be able to build a mutant system library (whatever AIX uses for dll/so) that intercepts the date system call and passes everything else on to the real lib. I can think of several way that would fail and several more why it's not a good idea, but it could work.

Related

Can I to know if ipad was rebooted?

I am developing an application that must work online and also offline. This application should sync informations with our server. For this, we need that the device utilize the server clock.
I found a lot of information, and I get the following idea:
When the user logins online I will force him to get the server clock time. In this moment he obrigatory must have internet connection, so it is ok.
When I get the clock server time, I get the systemUptime information that says the interval that the device is turned on, and I store it. I can get systemUptime like this:
[NSProcessInfo processInfo].systemUptime
When the user to create a new local file, I will know the current interval based on systemUptime function, so I know the current time, and I don't depend the iOS system clock.
The problem is: Everytime that device is rebooted, or turned off, the systemUptime is reseted. Until here OK, I can solve it forcing the user to login again, and getting the server clock time again. My problem is to know when the device was rebooted. Can you help me? Thank you guys!
My advice would be to not refer to the device time at all. Get the the files from the server and have the server also answer the server time that the files are retrieved. You can store this in the file, in the file name, or separately on the device.
At some point in the future ask the server if there's a file newer than the server time you recorded earlier.
In this sense, the time isn't really a time at all, it's a version number, and you could make that explicit with the server too, using just an integer from the server that indicates progressing sequence of versions.
If it's important that your app be strong in this way, your only choice is to remain independent of device time. Otherwise, there are too many ways it can break (including small time errors due to latency on the time check, or device factory resets or malicious actions by a user). It's better to remain independent of device time if you can.
When you get the systemUptime the first time, subtract it from the current (iOS) date and time. That's the time the system was last brought up.
Then recalculate this value whenever necessary. If the "time the system was last brought up" has changed, then you know it's time to log in again.
However, as suggested by another commenter, I suspect there's a better way to tackle this from scratch.

Is there any way to get the tamper-proof date and time on iPhone?

For various reasons I need to get from the iPhone the current date and time that can't be meddled with by the user. Yes, I've seen how one can check a server (e.g., here), but that's not invulnerable to tampering if you take a moment to reflect.
There are two knee-jerk reactions I'm expecting to hear:
Use the GPS time.
It can't be done.
In answer to another question, I've described my researches into this matter. To summarize them:
The GPS time shifts with the user-defined settings.
The iPhone definitely has an internal tamper-proof time and date, as shown when date-time reverts after Set Automatically in Settings > General > Time & Date is turned back to on even in a fallout shelter.
What I want to know is how to access this tamper-proof time.
Edit
Just to be clear, the server-based solution is not suitable. For one, it could be faked. For another, the app needs to work without a network connection.
Assuming you always have Internet available, you could implement a class or object that connects to a remote Network Time Protocol server.
Here's an open source GitHub project that should get you started, and the related StackOverflow question I found it at.

File syncronization between iPhone and a server

Can anyone suggest the best framework, method, library I could use in iPhone (use in development, not a ready application) in order to achieve syncronization between a fileserver and a local storadge on iPhone ?
I am doing this for one of my apps and the way I've implemented it is using a Ruby & Sinatra webserver, talking to a MongoDB database. You could use any other database and webserver technology.
The basic concept is this:
Every time an object in the database is updated, the timestamp is recorded for that object.
A global, last updated timestamp is also updated.
The app contacts the webserver and asks for updates, passing along a locally stored "last updated" timestamp.
The webserver processes the request by first checking the global timestamp and making sure it is older than the app's timestamp. (This is to save having to scour the database if no changes were made to it. My model is: Big data that is not changed frequently. If you have data that changes frequently, then there is probably no benefit to this global timestamp.)
The webserver then finds every object in the database whose timestamp is newer than the app's timestamp.
The webserver packages this up inside a JSON object, and returns it to the app.
This is all RESTful in the sense that it is a stateless transaction, so the app's implementation is very simple (a simple NSURLRequest, followed by JSON decoding, followed by error handling). Now you have an array of updated objects and you can merge these with your local storage in the app.
Another nice point about this (stateless) approach is that you can run it on Heroku (for free).
From what I can tell, there is no easy way. I was looking for an rsync equivalent, but I haven't found one.
In my case, I'm manually walking the tree asking the server for differences after a certain date and I remember the last successful sync date.
Not pretty. Could spend lots of time coming up with something sophisticated.

I need to programmatically set the date the OS returns to Java

I need to set the date that JVM would normally get from the OS.
Why? We have an app that interacts with a legacy app. All data on the legacy is always some date in the past (the client does reporting on a saved copy of live data (yesterday's data ) so as not to affect the response time of transactions on the live machine and demo's are done on dev machines, also some date in the past)
Our app needs to post transactions no later than the date on the legacy app. The legacy app lives on a different server. We have a process that returns the current date of the data and need to get the Java app to work entirely on that date.
We can't change the system date since a datawarehouse also runs on that box. So the only alternative is to change the date that JVM thinks it's getting from the OS.
Any ideas?
Own java agent should do the trick:
http://blogs.captechconsulting.com/blog/david-tiller/not-so-secret-java-agents-part-1
I suppose that intercepting System.currentTimeMillis() calls should be enough.

Is it possible to get a users timezone for an application hosted by Citrix XenApp?

I have a VB6 application hosted to users around the world through Citrix XenApp. I'm using the windows GetTimeZoneInformation call to find the time zone of the user in order to adjust some dates shown in the app (the dates come to the app in GMT). Unfortunately it looks like GetTimeZoneInformation gets the timezone of the Citrix server rather than the user running the application. Is there a Citrix based solution for this or am I going to need to change my implementation? This seems like a pretty big hole for Citrix hosted apps as I imagine you'd have the same problem with other localization settings.
What you ask should happen automatically: that applications do not get the server's but the client's time zone when asking Windows for the time zone. Here is a good description of how this works (PortICA, by the way, was a kind of early code name for XenDesktop).
If it does not work: client time zone support can be disabled, or any number of other things may have gone wrong. Check Citrix KB article CTX303498 for possible solutions.