licentivo-sdk 0.11.5 → 0.11.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb2068e66ec94daf6230590f0e85bf78dea783f3c52a49cf3c926dc45962c557
4
- data.tar.gz: 41c2941a07a16324c88cc6eb1b199e35833eca2bd58ef67f131405df800c8110
3
+ metadata.gz: e7efe812587e7e809a7318d9e714d45985ce91094fb17b2093f11c63e8fb31ae
4
+ data.tar.gz: 2d7ce444e510632a2ef68c9c4a2be55171471ef7300b27cded30432308ac8251
5
5
  SHA512:
6
- metadata.gz: c40659cedf3386d9bb5eecd59eff96bff974d9e342c33744a8b073ff50679eeec857fc2a45fc84ca1d7998af752c42f076f7dbde119e295b4e43038d0b918d78
7
- data.tar.gz: f3b194d1c08018b6532a86a032bf4202b97cd68d41654f31d4025512feef2715a1832a3e48f7be9057783d0a44e88878ad1ed207abf0be3ab205f5acaa8ccbdb
6
+ metadata.gz: ebf82984d5d529cbae4e1e48780305646519200a718cb426445ca8a7f8a109d76bdfa78c40d84e8295a904debc87caacb691890e5f2e17408dc83a52284f99d1
7
+ data.tar.gz: a77e341c743690476bb2085c1ba157e7d6657d3fdb896a49fe4abf1f2ba84e76fa3392aa21de036347d05cd0f22243e6c3e8e404b05bcba19f8593bf4e401919
data/README.md CHANGED
@@ -13,10 +13,10 @@ Requirements: Ruby 3.1+, Fiddle, C11 compiler and libcurl development files. Sou
13
13
  Install the public SDK package in your existing application project:
14
14
 
15
15
  ```sh
16
- gem install licentivo-sdk --version 0.11.5
16
+ gem install licentivo-sdk --version 0.11.6
17
17
  ```
18
18
 
19
- For Bundler, use `gem "licentivo-sdk", "= 0.11.5"` in your Gemfile.
19
+ For Bundler, use `gem "licentivo-sdk", "= 0.11.6"` in your Gemfile.
20
20
 
21
21
  No SDK source download, extraction or local path dependency is required.
22
22
 
data/lib/licentivo.rb CHANGED
@@ -4,7 +4,7 @@ require 'json'
4
4
  require 'monitor'
5
5
 
6
6
  module Licentivo
7
- VERSION = '0.11.5'
7
+ VERSION = '0.11.6'
8
8
 
9
9
  class Error < StandardError
10
10
  attr_reader :code, :http_status, :request_id, :retryable, :retry_after_seconds
data/native/licentivo.c CHANGED
@@ -186,6 +186,24 @@ static int hash(const char*s,char out[65]){unsigned char raw[32]={0};int ok=0;
186
186
  out[64]=0;
187
187
  return 1;
188
188
  }
189
+ #if defined(__APPLE__) || defined(LICENTIVO_TEST_PLATFORM_LINES)
190
+ /* A host runtime can interrupt pipe reads with a signal. Preserve the partial
191
+ * line while retrying EINTR so an interrupted ioreg read cannot change the
192
+ * device identity or make an otherwise valid configuration fail. */
193
+ static char*platform_read_line(FILE*stream,char*line,size_t capacity){
194
+ if(capacity<2)return NULL;
195
+ size_t used=0;
196
+ while(used+1<capacity){
197
+ errno=0;int ch=fgetc(stream);
198
+ if(ch==EOF){
199
+ if(ferror(stream)){if(errno==EINTR){clearerr(stream);continue;}return NULL;}
200
+ break;
201
+ }
202
+ line[used++]=(char)ch;if(ch=='\n')break;
203
+ }
204
+ line[used]=0;return used?line:NULL;
205
+ }
206
+ #endif
189
207
  /* OS identity is read locally; app folders and cache files cannot provide it. */
190
208
  static int system_device_id(const char*product,char out[65]){
191
209
  if(!uuid(product))return 0;
@@ -197,7 +215,7 @@ static int system_device_id(const char*product,char out[65]){
197
215
  if(result!=ERROR_SUCCESS||type!=REG_SZ||size>=sizeof(identity))return 0;
198
216
  #elif defined(__APPLE__)
199
217
  FILE*f=popen("/usr/sbin/ioreg -rd1 -c IOPlatformExpertDevice","r");if(!f)return 0;char line[2048];
200
- while(fgets(line,sizeof(line),f)){char*p=strstr(line,"\"IOPlatformUUID\"");if(!p)continue;p=strchr(p,'=');if(!p)continue;p=strchr(p,'"');if(!p)continue;p++;char*end=strchr(p,'"');if(end&&end-p<127){memcpy(identity,p,(size_t)(end-p));break;}}
218
+ while(platform_read_line(f,line,sizeof(line))){char*p=strstr(line,"\"IOPlatformUUID\"");if(!p)continue;p=strchr(p,'=');if(!p)continue;p=strchr(p,'"');if(!p)continue;p++;char*end=strchr(p,'"');if(end&&end-p<127){memcpy(identity,p,(size_t)(end-p));break;}}
201
219
  pclose(f);
202
220
  #else
203
221
  const char*paths[]={"/etc/machine-id","/var/lib/dbus/machine-id"};for(int i=0;i<2;i++){FILE*f=fopen(paths[i],"rb");if(!f)continue;size_t n=fread(identity,1,127,f);fclose(f);identity[n]=0;if(n)break;}
@@ -224,7 +242,7 @@ static cJSON*machine_profile(const char*product,char dev[65]){
224
242
  char command[]="powershell.exe -NoProfile -NonInteractive -Command \"(Get-CimInstance Win32_ComputerSystemProduct).UUID; $v=Get-CimInstance Win32_ComputerSystem; $v.Manufacturer; $v.Model\"";
225
243
  if(CreateProcessA(NULL,command,NULL,NULL,TRUE,CREATE_NO_WINDOW,NULL,NULL,&startup,&process)){CloseHandle(writer);writer=NULL;if(WaitForSingleObject(process.hProcess,5000)==WAIT_TIMEOUT)TerminateProcess(process.hProcess,1);DWORD n=0;ReadFile(reader,description,sizeof(description)-1,&n,NULL);description[n]=0;CloseHandle(process.hProcess);CloseHandle(process.hThread);const char*end=strchr(description,'\n');size_t len=end?(size_t)(end-description):strlen(description);if(len<sizeof(hardware))memcpy(hardware,description,len);}if(writer)CloseHandle(writer);CloseHandle(reader);}
226
244
  #elif defined(__APPLE__)
227
- platform="darwin";FILE*f=popen("/usr/sbin/ioreg -rd1 -c IOPlatformExpertDevice","r");if(f){char line[2048];while(fgets(line,sizeof(line),f)){if(strstr(line,"VMware")||strstr(line,"Parallels"))strcpy(description,"virtual machine");char*p=strstr(line,"\"IOPlatformUUID\"");if(!p)continue;p=strchr(p,'=');if(!p)continue;p=strchr(p,'"');if(!p)continue;p++;char*end=strchr(p,'"');if(end&&end-p<127)memcpy(hardware,p,(size_t)(end-p));}pclose(f);}
245
+ platform="darwin";FILE*f=popen("/usr/sbin/ioreg -rd1 -c IOPlatformExpertDevice","r");if(f){char line[2048];while(platform_read_line(f,line,sizeof(line))){if(strstr(line,"VMware")||strstr(line,"Parallels"))strcpy(description,"virtual machine");char*p=strstr(line,"\"IOPlatformUUID\"");if(!p)continue;p=strchr(p,'=');if(!p)continue;p=strchr(p,'"');if(!p)continue;p++;char*end=strchr(p,'"');if(end&&end-p<127)memcpy(hardware,p,(size_t)(end-p));}pclose(f);}
228
246
  #else
229
247
  platform="linux";FILE*f=fopen("/sys/class/dmi/id/product_uuid","rb");if(f){size_t n=fread(hardware,1,sizeof(hardware)-1,f);hardware[n]=0;fclose(f);}const char*paths[]={"/sys/class/dmi/id/sys_vendor","/sys/class/dmi/id/product_name","/.dockerenv"};for(int i=0;i<3;i++){f=fopen(paths[i],"rb");if(f){if(i==2)strcat(description," virtual machine");else{size_t used=strlen(description),n=fread(description+used,1,512,f);description[used+n]=0;strcat(description," ");}fclose(f);}}
230
248
  #endif
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: licentivo-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.5
4
+ version: 0.11.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Licentivo