不管这个麻烦是否真的值得付出努力,您都可以检查普遍存在的文件(例如 Linux 中的 /etc/passwd)的访问时间并将其与当前日期进行比较。如果您发现这些文件将来被访问/修改,您就知道存在问题。同样,至少在 *nix 中,用户可以替换系统的 stat,以便它“按摩”您正在查看的信息。
Regardless with the question whether or not this hassle is really worth the effort, you can check access times of ubiquitous files (e.g. /etc/passwd in Linux) and compare these to the current date. If you see that the files have been accessed/modified in the future, you know that there is a problem. Again, at least in *nix, a user may substitute system's stat, so that it "massages" the info you are looking at.
Of course, this will only work if the user doesn't block your program from accessing the internet. And what should your program do when it can't access the internet? Refuse to run? I doubt that this is a good idea.
发布评论
评论(3)
不管这个麻烦是否真的值得付出努力,您都可以检查普遍存在的文件(例如 Linux 中的 /etc/passwd)的访问时间并将其与当前日期进行比较。如果您发现这些文件将来被访问/修改,您就知道存在问题。同样,至少在 *nix 中,用户可以替换系统的 stat,以便它“按摩”您正在查看的信息。
Regardless with the question whether or not this hassle is really worth the effort, you can check access times of ubiquitous files (e.g. /etc/passwd in Linux) and compare these to the current date. If you see that the files have been accessed/modified in the future, you know that there is a problem. Again, at least in *nix, a user may substitute system's stat, so that it "massages" the info you are looking at.
您可以通过互联网从外部来源获取时间: Python Getting date online?
当然,仅当用户不阻止您的程序访问互联网时,这才有效。当你的程序无法访问互联网时应该做什么?拒绝跑步?我怀疑这是一个好主意。
You could get the time from an external source via Internet: Python Getting date online?
Of course, this will only work if the user doesn't block your program from accessing the internet. And what should your program do when it can't access the internet? Refuse to run? I doubt that this is a good idea.
几乎每个标准函数都会返回可由用户调整的机器时间。
一种可能性是调用返回“正确”时间的 Web 服务。但这只有在您可以访问互联网的情况下才有可能。
也许应该问自己这个问题是否真的值得付出努力?
Nearly every standard function will return the machine time that can be adjusted by the user.
One possibility is to call a web service that returns the "correct" time. But this is only possible if you can assume internet access.
And may be should ask your self the question if that hassle is really worth the effort?