diff --git a/.gitignore b/.gitignore
index a235188e..023edd02 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,7 @@ lib-cov
# Coverage directory used by tools like istanbul
coverage
+.nyc_output
# node-waf configuration
.lock-wscript
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4d5a2a85..45d77761 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fix stringification issue on handling 207 [#152](https://github.com/logdna/logdna-agent/pull/152)
- Fix memory leak issue [#157](https://github.com/logdna/logdna-agent/pull/157)
+- Make sure `process.getuid` doesn't get called on `Windows` [#188](https://github.com/logdna/logdna-agent/pull/188)
## [1.6.2] - December 5, 2019
### Added
diff --git a/index.js b/index.js
index 7f2794b2..d95327ed 100644
--- a/index.js
+++ b/index.js
@@ -63,8 +63,8 @@ commander
console.log()
})
-function loadConfig(program, uid) {
- if ((os.platform() === 'win32' && require('is-administrator')()) || uid <= 0) {
+function loadConfig(program, isAdmin) {
+ if (isAdmin) {
const conf_file = program.config || config.DEFAULT_CONF_FILE
debug(`Path to Configuration File: ${conf_file}`)
async.waterfall([
@@ -307,7 +307,7 @@ process.on('uncaughtException', err => utils.log(`uncaught error: ${(err.stack |
if (require.main === module) {
commander.parse(process.argv)
- loadConfig(commander, process.getuid())
+ loadConfig(commander, os.platform() === 'win32' ? require('is-administrator')() : process.getuid() === 0)
}
module.exports = {
diff --git a/test/unit/index.js b/test/unit/index.js
index 1e9bd2ed..61f51d36 100644
--- a/test/unit/index.js
+++ b/test/unit/index.js
@@ -6,7 +6,7 @@ const fs = require('fs')
const {test} = require('tap')
const {loadConfig, commander} = require('../../index.js')
-const uid = 0
+const isAdmin = true
test('Commander help output', (t) => {
commander.outputHelp((help) => {
@@ -23,7 +23,7 @@ test('loadConfig() settings based on user input', async (t) => {
t.test('Errors if no key is found', (tt) => {
loadConfig({
config: configFile
- }, uid)
+ }, isAdmin)
setTimeout(() => {
fs.stat(configFile, (err) => {
@@ -42,7 +42,7 @@ test('loadConfig() settings based on user input', async (t) => {
, hostname: 'myMachine'
}
- loadConfig(input, uid)
+ loadConfig(input, isAdmin)
// The callback is not exposed. We have to wait for the file to be written to.
setTimeout(() => {
@@ -64,7 +64,7 @@ test('loadConfig() settings based on user input', async (t) => {
, logdir: logs
}
- loadConfig(input, uid)
+ loadConfig(input, isAdmin)
setTimeout(() => {
const contents = (fs.readFileSync(configFile, 'utf8')).split('\n').sort()
@@ -91,7 +91,7 @@ test('loadConfig() settings based on user input', async (t) => {
, tags
}
- loadConfig(input, uid)
+ loadConfig(input, isAdmin)
setTimeout(() => {
const contents = (fs.readFileSync(configFile, 'utf8')).split('\n')
@@ -128,7 +128,7 @@ test('loadConfig() settings based on user input', async (t) => {
loadConfig({
config: configFile
, unset: ['set1']
- }, uid)
+ }, isAdmin)
setTimeout(() => {
const contents = (fs.readFileSync(configFile, 'utf8')).split('\n')
@@ -148,7 +148,7 @@ test('loadConfig() settings based on user input', async (t) => {
loadConfig({
config: configFile
, unset: ['all']
- }, uid)
+ }, isAdmin)
setTimeout(() => {
const contents = (fs.readFileSync(configFile, 'utf8'))
@@ -167,7 +167,7 @@ test('loadConfig() hostname decisions', async (t) => {
, key: 'abc123'
}
- loadConfig(input, uid)
+ loadConfig(input, isAdmin)
// The callback is not exposed. We have to wait for the file to be written to.
setTimeout(() => {
@@ -211,7 +211,7 @@ test('Process options through commander', (t) => {
]
commander.parse(input)
- loadConfig(commander, uid)
+ loadConfig(commander, isAdmin)
setTimeout(() => {
const contents = (fs.readFileSync(configFile, 'utf8')).split('\n').sort()
diff --git a/tools/files/win32/logdna-agent.nuspec b/tools/files/win32/logdna-agent.nuspec
index 0f3167b4..6eb18370 100644
--- a/tools/files/win32/logdna-agent.nuspec
+++ b/tools/files/win32/logdna-agent.nuspec
@@ -8,10 +8,6 @@
smusali,leeliu
leeliu
LogDNA Agent for Windows
- 1.6.3
- smusali,leeliu
- leeliu
- LogDNA Agent for Windows
LogDNA Collector Agent Streaming File and Event Logs to LogDNA.
https://logdna.com/
https://github.com/logdna/logdna-agent
diff --git a/tools/scripts/darwin.sh b/tools/scripts/darwin.sh
index 8048e728..c6c0bcbf 100644
--- a/tools/scripts/darwin.sh
+++ b/tools/scripts/darwin.sh
@@ -52,7 +52,8 @@ cd ../.pkg
mv ../.build/logdna-agent-${VERSION}.pkg logdna-agent-${VERSION}-unsigned.pkg
productsign --sign "Developer ID Installer: Answerbook, Inc. (TT7664HMU3)" logdna-agent-${VERSION}-unsigned.pkg logdna-agent-${VERSION}.pkg
SHA256CHECKSUM=$(shasum -a 256 logdna-agent-${VERSION}.pkg | cut -d' ' -f1)
-sed "s/$(cat ../tools/files/darwin/logdna-agent.rb | grep sha256 | cut -d"'" -f2)/${SHA256CHECKSUM}/" ../tools/files/darwin/logdna-agent.rb > logdna-agent.rb
+OLDSHA256CHECKSUM=$(cat ../tools/files/darwin/logdna-agent.rb | grep sha256 | cut -d"'" -f2)
+sed "s/${OLDSHA256CHECKSUM}/${SHA256CHECKSUM}/" ../tools/files/darwin/logdna-agent.rb > logdna-agent.rb
cd ..
# STEP 4: RELEASE
diff --git a/tools/scripts/win32.sh b/tools/scripts/win32.sh
index 346c1600..a4f9c9b2 100644
--- a/tools/scripts/win32.sh
+++ b/tools/scripts/win32.sh
@@ -24,9 +24,10 @@ nexe -i index.js -o .build/tools/${PACKAGE_NAME}.exe -t win32-${ARCH}-${NODE_VER
# STEP 2: PACKAGE
cd .build/
-sed -i "s/latest/${VERSION}/" tools/VERIFICATION.txt
+sed "s/latest/${VERSION}/" ./tools/VERIFICATION.txt > ./tools/VERIFICATION.txt
SHA256CHECKSUM=$(shasum -a 256 tools/${PACKAGE_NAME}.exe | cut -d' ' -f1)
-sed -i "s/$(cat tools/VERIFICATION.txt | grep 'checksum: ' | cut -d' ' -f4)/${SHA256CHECKSUM}/" tools/VERIFICATION.txt
+OLDSHA256CHECKSUM=$(cat tools/VERIFICATION.txt | grep 'checksum: ' | cut -d' ' -f4)
+sed "s/${OLDSHA256CHECKSUM}/${SHA256CHECKSUM}/" ./tools/VERIFICATION.txt > ./tools/VERIFICATION.txt
choco pack logdna-agent.nuspec
cd ..
cp .build/*.nupkg .build/tools/*.exe .pkg/