简体   繁体   English

可执行文件中的时间限制

[英]Time limit in an executable

How can I make an executable in linux ubuntu with time constraint meaning that I want the executable to run only for 90 days in the machine where I deploy it? 如何在有时间限制的linux ubuntu中制作可执行文件,这意味着我希望该可执行文件在部署它的计算机中仅运行90天? So the user can only use the executable for 90 days and not more. 因此,用户只能在90天之内使用该可执行文件,而不能使用更多时间。 Similar to some softwares which has free trial period for 1 month. 类似于某些具有1个月免费试用期的软件。

While it is difficult to guard against modification of the executable file, in theory you can do this with a trivial implimentation in your code. 虽然很难防止修改可执行文件,但是从理论上讲,您可以在代码中包含一些琐碎的内容。

For example, in C: 例如,在C中:

int main() {
  if (time(NULL) > xxxxxxxxxxxx) {
    return 0;
  }
}

This relies on setting the time to expire at compile-time. 这取决于设置在编译时到期的时间。

If you want to have the trial last a certain period , rather than expire at a particular predetermined time, then you would have to get the program to write a file on first execution that specifies the time it was run. 如果您希望试用期持续一定的时间 ,而不是在特定的预定时间到期,那么您将必须让程序在首次执行时写一个文件来指定运行时间。 You can then later compare the current time with this file. 然后,您可以稍后将当前时间与此文件进行比较。

These methods can be avoided by savvy users, and so you may wish to pursue other methods, perhaps increasing obscurity, or involving some server that you own in a critical software function. 精明的用户可以避免使用这些方法,因此您可能希望采用其他方法,可能会增加晦涩感,或者使您拥有的某些服务器参与关键软件功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM