origin icon indicating copy to clipboard operation
origin copied to clipboard

Error: Operation not permitted while using raw-socket for net-ping module

Open nr-mjuvvadi opened this issue 7 months ago • 0 comments

I am using net-ping module in my container which runs on openshift environment as non root user.

I am getting below error when running script in my pod

var ping = require('net-ping')
ping.createSession({
  retries: 2,
  timeout: 1000
});

Error:

Error: Operation not permitted
at new Socket (/app/api-runtime/.yarn/unplugged/raw-socket-npm-1.7.0-8205b5d49b/node_modules/raw-socket/index.js:47:14)
at Object.exports.createSocket (/app/api-runtime/.yarn/unplugged/raw-socket-npm-1.7.0-8205b5d49b/node_modules/raw-socket/index.js:202:9)

I have NET_RAW and NET_ADMIN capabilities added to my custom SCC which I have defined for the user and this is getting reflected in my pod yaml as well as shown. Any way I can fix this.

I have tried adding setcap CAP_NET_RAW+eip /usr/bin/node but it didnt help

Image

nr-mjuvvadi avatar May 06 '25 16:05 nr-mjuvvadi