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 +4 -4
- data/README.md +2 -2
- data/lib/licentivo.rb +1 -1
- data/native/licentivo.c +20 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e7efe812587e7e809a7318d9e714d45985ce91094fb17b2093f11c63e8fb31ae
|
|
4
|
+
data.tar.gz: 2d7ce444e510632a2ef68c9c4a2be55171471ef7300b27cded30432308ac8251
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
16
|
+
gem install licentivo-sdk --version 0.11.6
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
For Bundler, use `gem "licentivo-sdk", "= 0.11.
|
|
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
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(
|
|
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(
|
|
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
|